Skip to content
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

Compilation with Clang #830

Open
corepointer opened this issue Sep 24, 2024 · 2 comments · May be fixed by #831
Open

Compilation with Clang #830

corepointer opened this issue Sep 24, 2024 · 2 comments · May be fixed by #831
Labels
bug A mistake in the code. feature missing/requested features

Comments

@corepointer
Copy link
Collaborator

At the moment, compiling with clang fails at least for me. Errors start with this:

/daphne/src/parser/daphnedsl/DaphneDSLVisitor.cpp:1487:51: error: 'auto' not allowed in template argument                                                                                                                                                  
 1487 |                        int64_t i, std::pair<bool, auto> constValue) {                                                
      |                                                   ^~~~                                                                                                                                                                                             
/daphne/src/parser/daphnedsl/DaphneDSLVisitor.cpp:1508:21: error: no matching function for call to object of type '(lambda at /daphne/src/parser/daphnedsl/DaphneDSLVisitor.cpp:1486:20)'                                                                  
 1508 |                     fillRes(i,                      
      |                     ^~~~~~~                                                                                          
/daphne/src/parser/daphnedsl/DaphneDSLVisitor.cpp:1658:47: note: in instantiation of function template specialization 'DaphneDSLVisitor::buildColMatrixFromValues<long>' requested here                                                                    
 1658 |                 colMatrix = DaphneDSLVisitor::buildColMatrixFromValues<int64_t>(                                                                                                                                                                   
      |                                               ^                                                                                                                                                                                                    
/daphne/src/parser/daphnedsl/DaphneDSLVisitor.cpp:1486:20: note: candidate function not viable: no known conversion from 'std::pair<bool, long>' to 'int' for 2nd argument
 1486 |     auto fillRes = [&constValues, &nonConstValsIdx](                                                                                                                                                                                               
      |                    ^                                                                                                                                                                                                                               
 1487 |                        int64_t i, std::pair<bool, auto> constValue) {                                                                                                                                                                              
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   

This goes on until it stops with

fatal error: too many errors emitted, stopping now [-ferror-limit=]                                                          

Clang version in the daphne-dev Docker container is the default of Ubuntu 24:

@daphne-container:/daphne$ clang -v
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /bin
Found candidate GCC installation: /bin/../lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /bin/../lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
@corepointer
Copy link
Collaborator Author

From what I found out here, the issue described above is that the use of auto as a parameter of std::pair is only working in gcc and actually ill formed.

@corepointer corepointer added the feature missing/requested features label Sep 24, 2024
@corepointer
Copy link
Collaborator Author

@philipportner I fixed this issue and it's compiling (with loads of warnings though).

corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
Compiling with Clang/LLD complains about duplicate symbols of supportBinaryOp
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
… local static template function

std::pair<bool, auto> was used as a convenience function in DaphneDSLVisitor.cpp. According to [1] this is invalid and only works with GCC. Replacing it with a templated local function makes Clang compile it too. Further improvements to this file will be considered in future commit.

[1] https://stackoverflow.com/questions/59578575/stdpairauto-auto-return-type
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
…ith Clang

When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local".
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
The use of EOF in our json dependency makes compilation fail with Clang
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
To accommodate various new language features, we switch the used C++ version to C++20. Tagging this to the Clang compile issue daphne-eu#830 as one of the fixes uses make_shared<[]>.
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
Compiling with Clang/LLD complains about duplicate symbols of supportsUnaryOp and supportsBinaryOp.
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
… local static template function

std::pair<bool, auto> was used as a convenience function in DaphneDSLVisitor.cpp. According to [1] this is invalid and only works with GCC. Replacing it with a templated local function makes Clang compile it too. Further improvements to this file will be considered in future commit.

[1] https://stackoverflow.com/questions/59578575/stdpairauto-auto-return-type
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
…ith Clang

When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local".
corepointer added a commit to corepointer/daphne that referenced this issue Sep 24, 2024
…endency

The use of EOF in our json dependency makes compilation fail with Clang.
Patch is based on nlohmannjson version 3.11.3
corepointer added a commit to corepointer/daphne that referenced this issue Oct 4, 2024
Compiling with Clang/LLD complains about duplicate symbols of supportsUnaryOp and supportsBinaryOp.
The definition of supportsBinaryOp would need to be declared static if left i the BinaryOpCode.h header which is included in several places.
Since this definition is not allowed and there is only one use, it is moved to its own file.
corepointer added a commit to corepointer/daphne that referenced this issue Oct 4, 2024
… local static template function

std::pair<bool, auto> was used as a convenience function in DaphneDSLVisitor.cpp. According to [1] this is invalid and only works with GCC. Replacing it with a templated local function makes Clang compile it too. Further improvements to this file will be considered in future commit.

[1] https://stackoverflow.com/questions/59578575/stdpairauto-auto-return-type
corepointer added a commit to corepointer/daphne that referenced this issue Oct 4, 2024
…ith Clang

When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local".
corepointer added a commit to corepointer/daphne that referenced this issue Oct 4, 2024
…endency

The use of EOF in our json dependency makes compilation fail with Clang.
Patch is based on nlohmannjson version 3.11.3
corepointer added a commit to corepointer/daphne that referenced this issue Oct 4, 2024
With this new CMake configuration, we silence a lot of warnings when using the LLD linker in combination with clang:
``clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]``

A CMake version bump to 3.29 is necessary for this config option. Ubuntu 24 users need to switch to the snap version of CMake. The Docker images already provide CMake 3.30
@corepointer corepointer linked a pull request Oct 4, 2024 that will close this issue
2 tasks
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
Compiling with Clang/LLD complains about duplicate symbols of supportsUnaryOp and supportsBinaryOp.
The definition of supportsBinaryOp would need to be declared static if left i the BinaryOpCode.h header which is included in several places.
Since this definition is not allowed and there is only one use, it is moved to its own file.
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
… local static template function

std::pair<bool, auto> was used as a convenience function in DaphneDSLVisitor.cpp. According to [1] this is invalid and only works with GCC. Replacing it with a templated local function makes Clang compile it too. Further improvements to this file will be considered in future commit.

[1] https://stackoverflow.com/questions/59578575/stdpairauto-auto-return-type
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
…ith Clang

When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local".
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
…endency

The use of EOF in our json dependency makes compilation fail with Clang.
Patch is based on nlohmannjson version 3.11.3
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
With this new CMake configuration, we silence a lot of warnings when using the LLD linker in combination with clang:
``clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]``

A CMake version bump to 3.29 is necessary for this config option. Ubuntu 24 users need to switch to the snap version of CMake. The Docker images already provide CMake 3.30
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
This commit adds the convenience option to build with Clang to the build.sh script
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
This commit enables compiling DAPHNE with Clang (tested version 18.1.3 from Ubuntu 24 LTS). Below is the collected change log of the pre-squash commits:

[DAPHNE-daphne-eu#830] Fix duplicate symbol linker issue

Compiling with Clang/LLD complains about duplicate symbols of supportsUnaryOp and supportsBinaryOp.
The definition of supportsBinaryOp would need to be declared static if left i the BinaryOpCode.h header which is included in several places.
Since this definition is not allowed and there is only one use, it is moved to its own file.

[DAPHNE-daphne-eu#830] Replace lambda function using invalid C++ with local static template function

std::pair<bool, auto> was used as a convenience function in DaphneDSLVisitor.cpp. According to [1] this is invalid and only works with GCC. Replacing it with a templated local function makes Clang compile it too. Further improvements to this file will be considered in future commit.

[1] https://stackoverflow.com/questions/59578575/stdpairauto-auto-return-type

[DAPHNE-daphne-eu#830] Fix anonymous namespace issue when compiling with Clang

When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local".

[DAPHNE-daphne-eu#830] Fix compilation error (with clang) in json dependency

The use of EOF in our json dependency makes compilation fail with Clang.
Patch is based on nlohmannjson version 3.11.3

[DAPHNE-daphne-eu#830] Silence warning when using LLD

With this new CMake configuration, we silence a lot of warnings when using the LLD linker in combination with clang:
``clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]``

A CMake version bump to 3.29 is necessary for this config option. Ubuntu 24 users need to switch to the snap version of CMake. The Docker images already provide CMake 3.30

[DAPHNE-daphne-eu#830] Clang option for build.sh

This commit adds the convenience option to build with Clang to the build.sh script

Resolves daphne-eu#830, Closes daphne-eu#831
corepointer added a commit to corepointer/daphne that referenced this issue Oct 6, 2024
This commit enables compiling DAPHNE with Clang (tested version 18.1.3 from Ubuntu 24 LTS). Below is the collected change log of the pre-squash commits:

[DAPHNE-daphne-eu#830] Fix duplicate symbol linker issue

Compiling with Clang/LLD complains about duplicate symbols of supportsUnaryOp and supportsBinaryOp.
The definition of supportsBinaryOp would need to be declared static if left i the BinaryOpCode.h header which is included in several places.
Since this definition is not allowed and there is only one use, it is moved to its own file.

[DAPHNE-daphne-eu#830] Replace lambda function using invalid C++ with local static template function

std::pair<bool, auto> was used as a convenience function in DaphneDSLVisitor.cpp. According to [1] this is invalid and only works with GCC. Replacing it with a templated local function makes Clang compile it too. Further improvements to this file will be considered in future commit.

[1] https://stackoverflow.com/questions/59578575/stdpairauto-auto-return-type

[DAPHNE-daphne-eu#830] Fix anonymous namespace issue when compiling with Clang

When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local".

[DAPHNE-daphne-eu#830] Fix compilation error (with clang) in json dependency

The use of EOF in our json dependency makes compilation fail with Clang.
Patch is based on nlohmannjson version 3.11.3

[DAPHNE-daphne-eu#830] Silence warning when using LLD

With this new CMake configuration, we silence a lot of warnings when using the LLD linker in combination with clang:
``clang++: warning: argument unused during compilation: '-fuse-ld=lld' [-Wunused-command-line-argument]``

A CMake version bump to 3.29 is necessary for this config option. Ubuntu 24 users need to switch to the snap version of CMake. The Docker images already provide CMake 3.30

[DAPHNE-daphne-eu#830] Clang option for build.sh

This commit adds the convenience option to build with Clang to the build.sh script

Resolves daphne-eu#830, Closes daphne-eu#831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A mistake in the code. feature missing/requested features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant