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

Add support for LLVM 10 #60

Merged
merged 8 commits into from
Jul 18, 2020
Merged

Add support for LLVM 10 #60

merged 8 commits into from
Jul 18, 2020

Conversation

acxz
Copy link
Contributor

@acxz acxz commented Jul 11, 2020

Resolves #59

@joaoleal
Copy link
Owner

joaoleal commented Jul 12, 2020

Hello,

There are some additional changes still needed for clang 10.0 support.
We need to replace the following in llvm_base_model_library_processor_impl.hpp:

        CompilerInvocation::setLangDefaults(*invocation->getLangOpts(), InputKind::C,
                                            llvm::Triple(invocation->TargetOpts->Triple),
                                            invocation->getPreprocessorOpts(),
                                            LangStandard::lang_unspecified);

with:

        CompilerInvocation::setLangDefaults(*invocation->getLangOpts(),
#if LLVM_VERSION_MAJOR >= 10
                                            InputKind(clang::Language::C),
#else
                                            InputKind::C,
#endif
                                            llvm::Triple(invocation->TargetOpts->Triple),
                                            invocation->getPreprocessorOpts(),
                                            LangStandard::lang_unspecified);

The following line needs to be added to llvm10_0.hpp:

#include  <clang/Basic/Builtins.h>

There is still another issue that I have not been able to solve. I have some local changes which allow me to compile but I still don't know what are the differences with your PR.
I'm having issues during the linking step:

[100%] Linking CXX executable llvm_link_clang
/usr/bin/ld: /usr/lib/llvm-10/lib/libclangCodeGen.a(BackendUtil.cpp.o): na função "(anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >)":
(.text._ZN12_GLOBAL__N_118EmitAssemblyHelper30EmitAssemblyWithNewPassManagerEN5clang13BackendActionESt10unique_ptrIN4llvm17raw_pwrite_streamESt14default_deleteIS5_EE+0x1f15): referência não definida para "getPollyPluginInfo()"
collect2: error: ld returned 1 exit status
make[3]: *** [test/cppad/cg/model/llvm/CMakeFiles/llvm_link_clang.dir/build.make:108: test/cppad/cg/model/llvm/llvm_link_clang] Error 1
make[2]: *** [CMakeFiles/Makefile2:3814: test/cppad/cg/model/llvm/CMakeFiles/llvm_link_clang.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:3821: test/cppad/cg/model/llvm/CMakeFiles/llvm_link_clang.dir/rule] Error 2
make: *** [Makefile:1475: llvm_link_clang] Error 2

@joaoleal
Copy link
Owner

joaoleal commented Jul 12, 2020

Another change is required. Replace in llvm_base_model_library_processor_impl.hpp:

ArrayRef<const char*> args {"-Wall", "-x", "c", "string-input"}; // -Wall or -v flag is required to avoid an error inside createInvocationFromCommandLine()

with:

std::vector<const char*> args {"-Wall", "-x", "c", "string-input"}; // -Wall or -v flag is required to avoid an error inside createInvocationFromCommandLine()

Also, I think llvm-10 needs to compile with C++14.
There this is still the issue with the linking. Similar problem here and here.

@acxz
Copy link
Contributor Author

acxz commented Jul 12, 2020

Ah yeah I was able to figure out the InputKind issue, but yes still getting linking issues. I can go ahead and close this PR and let you take it up. Don't think I have knowledge the completely implement this.

@joaoleal
Copy link
Owner

I was able to get it to link and run successfully.
I'm attaching a patch with my changes if you would like to implement it in this PR:
llvm-10.zip

@acxz
Copy link
Contributor Author

acxz commented Jul 13, 2020

Sweet! Yeah I can put your patch on top of this PR. I'll give it a go later today.

Co-authored-by: João Rui Leal <joaoruileal@gmail.com>
@acxz
Copy link
Contributor Author

acxz commented Jul 16, 2020

@joaoleal sorry for taking some time, a couple busy days.

I had to convert your patch to a patch I could use with the git apply command (apparently idea patches dont work off the bat).

@joaoleal joaoleal changed the base branch from master to develop July 18, 2020 17:04
@joaoleal joaoleal merged commit 837d0f8 into joaoleal:develop Jul 18, 2020
@acxz acxz deleted the llvm-10 branch July 18, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add support for LLVM 10
2 participants