-
Notifications
You must be signed in to change notification settings - Fork 149
GCC Compatibility #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
GCC Compatibility #787
Conversation
…related to json ser/de with LLVMAliasSet and LLVMBasedICFG that were not detected untio now, because of nlohmann's implicit conversions feature
CMakeLists.txt
Outdated
@@ -82,6 +82,11 @@ option(PHASAR_BUILD_MODULES "Build C++20 modules for phasar" OFF) | |||
|
|||
include(CheckCXXCompilerFlag) | |||
|
|||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | |||
# Match clang's behavior, when handling naming collisions, such as "using l_t = l_t;" | |||
string(APPEND CMAKE_CXX_FLAGS " -fpermissive") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would highly advice against adding permissive here. Permissive turns many actual errors into warnings/nothing. It is not recommended to be turned on.
Either we should fine another fix for the collisions or, even better, just fix them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree.
Fixed it
static constexpr auto isLLVMZeroValue = [](const llvm::Value *V) noexcept { | ||
return V == getInstance(); | ||
return isZeroValueHelper(V); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the underlying reason to have a lambda here instead of a normal static member?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -36,6 +36,10 @@ class LLVMZeroValue : public llvm::GlobalVariable { | |||
LLVMZeroValue(llvm::Module &Mod); | |||
|
|||
static constexpr llvm::StringLiteral LLVMZeroValueInternalName = "zero_value"; | |||
static bool isZeroValueHelper(const llvm::Value *V) noexcept { | |||
// Need this helper function to make gcc happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the problem here for gcc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For gcc, the type LLVMZeroValue is incomplete in the lambda, so it cannot perform the implicit conversion to pointer-to-base for the comparison V == getInstance()
@@ -942,6 +942,14 @@ class IDEInstInteractionAnalysisT | |||
|
|||
inline l_t join(l_t Lhs, l_t Rhs) override { return joinImpl(Lhs, Rhs); } | |||
|
|||
struct IIAAKillOrReplaceEF; | |||
struct IIAAAddLabelsEF; | |||
// These friend declarations are needed to make gcc happy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe add the problem here in the comment, it's a bit hard to figure out why you needed this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
struct IIAAKillOrReplaceEF; | ||
struct IIAAAddLabelsEF; | ||
// These friend declarations are needed to make gcc happy | ||
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume making them hidden friends was not an option because you would need the full def. for the implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we can simplify this, as we only need the friend on the IIA analysis class, not on the edge-functions.
Thanks for pointing that out!
Changed it.
Make phasar compile with gcc (g++-11 and g++-13) and uncover (and fix) two bugs related to json ser/de with LLVMAliasSet and LLVMBasedICFG that were not detected until now, because of nlohmann's implicit conversions feature.