Skip to content

Llvm conflict fix#8717

Merged
Axel-Naumann merged 6 commits into
root-project:masterfrom
grasph:llvm-conflict-fix
Nov 4, 2021
Merged

Llvm conflict fix#8717
Axel-Naumann merged 6 commits into
root-project:masterfrom
grasph:llvm-conflict-fix

Conversation

@grasph

@grasph grasph commented Jul 22, 2021

Copy link
Copy Markdown
Contributor

@vgvassilev, here is the PR so solve the LLVM library conflicts when interfacing ROOT with Julia. I've limited the change to the interpreter package.

I have 25 out of the 2140 tests that fail. It's likely to be due to my local environment. If it can easily be tested with the jenkins system, it will be faster that me trying to investigate the test failures.

Note. The parallel compilation is not working properly, independently of my changes: it fails many times and need to be restarted or build some package in single process mode. Is it a know problem ?

This Pull request:

Changes or fixes:

Adds -Bsymbolic linker option for libCling.so in order get the symbols resolved internally

This is expected to solve conflicts when interfacing with other software using LLVM, like Julia. See https://github.com/JuliaHEP/ROOT.jl/issues/17#issuecomment-882719292

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

@grasph grasph requested a review from bellenot as a code owner July 22, 2021 10:58
@phsft-bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@vgvassilev

Copy link
Copy Markdown
Member

@phsft-bot build!

@phsft-bot

Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@grasph

grasph commented Jul 22, 2021

Copy link
Copy Markdown
Contributor Author

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

* [projectroot.roottest.python.cpp.roottest_python_cpp_cpp](https://lcgapp-services.cern.ch/root-jenkins/job/root-pullrequests-build/123133/testReport/projectroot.roottest.python/cpp/roottest_python_cpp_cpp/)

@vgvassilev , I don't have this test in my checkout:

Test project /home/pgras/git.d/root.grasph/mybuild
No tests were found!!!

Do you have an idea why? I ran cmake with the following options as described in [1]:

cmake -DCMAKE_BUILD_TYPE=Debug -Dtesting=ON -Droottest=ON

Do I need more options? A pyroottest=ON ?

Philippe.

[1] https://root.cern/for_developers/run_the_tests/

@vgvassilev

Copy link
Copy Markdown
Member

@grasph, that is a regular failure and it is not caused by your PR.

@hahnjo

hahnjo commented Jul 22, 2021

Copy link
Copy Markdown
Member

We're already adding -fno-semantic-interposition since commit e564c8a / PR #8204 which I think should already set the visibility such that LLVM symbols are hidden from other libraries. Did you recently test a master build or 6.24/02?

@vgvassilev

Copy link
Copy Markdown
Member

@hahnjo, this patch is useful for cppyy and it sounds like -Bsymbolic covers more than VISIBILITY_INLINES_HIDDEN while also reducing the PLTs. In particular (ROOT master):

$ nm -CD libCling.so | grep llvm | grep ' [Ww] ' | wc -l
379

@grasph

grasph commented Jul 22, 2021

Copy link
Copy Markdown
Contributor Author

We're already adding -fno-semantic-interposition since commit e564c8a / PR #8204 which I think should already set the visibility such that LLVM symbols are hidden from other libraries. Did you recently test a master build or 6.24/02?

Interesting. From my understanding of g++ document, this flag with accidentally solves the problem if the compiler optimize the code by in-lining it but it is not guarranted. In addition it can create confusing situations where the problem disappears as soon as you try to debug it using the debugged version of the code.

That said, we are in a confusing situation, as I'm not able to reproduce the problem as soon as I recompile ROOT. Nevertheless, I recompiled many time ROOT last week, and then the problem was systematic. It could be that it is due to the ROOT code version I used.

The problem is there for LCG100 which used ROOT 6.24/00, but not for /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.24.02/x86_64-centos7-gcc48-opt/. So it would confirm that -fno-semantic-interposition has solved the problem if it has happened between the two versions. Nevertheless, as I wrote before, in my understanding, it's accidental and won't be as reliable as the -Bsymbolic option.

Philippe.

@Axel-Naumann

Axel-Naumann commented Jul 22, 2021

Copy link
Copy Markdown
Member

How is it accidental? It was totally on purpose, solving other occurrences of this exact same issue. I suppose, because i have not seen any issue / error message / backtrace, so all I can do is guess and assume :-) Can you please provide some details on the issue you try to fix? Can you please rebase this branch onto master? We do not allow merge commits (unless fast forward).

@Axel-Naumann

Copy link
Copy Markdown
Member

Iiuc https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic argues that -Bsymbolic should be fine for libCling and is superior to no symbolic interposition

@phsft-bot

Copy link
Copy Markdown

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

@grasph

grasph commented Jul 23, 2021

Copy link
Copy Markdown
Contributor Author

Iiuc https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic argues that -Bsymbolic should be fine for libCling and is superior to no symbolic interposition

Thanks, Axel, for the link to this interesting article. By "accidental", I meant that, if we assume the gcc manpage description of the flag correct and complete (*), then we rely on a side-effect of compiler optimizations. The article you quoted mention another optimization that should make it work for all calls to functions defined in the same compilation unit (**), while I wrote it will be limited to inline functions.

The -Bsymbolic, which is an option of the linker, instead of compiler, addresses directly what we target. The ld manpage description reads as "When creating a shared library, bind references to global symbols to the definition within the shared library, if any. "

Philippe.

(*) "with -fno-semantic-interposition the compiler assumes that if interposition happens for functions the overwriting function will have precisely the same semantics (and side effects). "

(**) Although the statement on LD_PRELOAD confuses me.

@Axel-Naumann Axel-Naumann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR!

Comment thread interpreter/CMakeLists.txt Outdated
Comment thread interpreter/CMakeLists.txt Outdated
@bellenot

Copy link
Copy Markdown
Member

@grasph please fork also roottest to prevent timeouts on the Windows build nodes. Thanks

@grasph

grasph commented Jul 23, 2021

Copy link
Copy Markdown
Contributor Author

@grasph please fork also roottest to prevent timeouts on the Windows build nodes. Thanks

Done. Do I need to create a branch with the same name ?

@bellenot

bellenot commented Jul 23, 2021

Copy link
Copy Markdown
Member

@grasph please fork also roottest to prevent timeouts on the Windows build nodes. Thanks

Done. Do I need to create a branch with the same name ?

Thanks. And no, simply forking is good enough

@grasph grasph requested a review from Axel-Naumann July 26, 2021 09:32
@grasph

grasph commented Jul 26, 2021

Copy link
Copy Markdown
Contributor Author

@bellenot I'm not sure why the PR is blocked. Is it an issue with deepcode-ci-bot or is github that did not get that I made the changed @Axel-Naumann requested? I'm leaving for holidays on Wednesday. It would be good to close the PR by then.

@pcanal

pcanal commented Jul 26, 2021

Copy link
Copy Markdown
Member

@phsft-bot build!

@phsft-bot

Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-26T21:21:09.750Z] stderr: error: Failed to merge in the changes.
  • [2021-07-26T21:21:13.231Z] CMake Error at /home/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1045 (message):

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-ubuntu16/nortcxxmod.
Running on sft-ubuntu-1604-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-26T21:21:19.121Z] stderr: error: Failed to merge in the changes.
  • [2021-07-26T21:21:25.023Z] CMake Error at /mnt/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1045 (message):

@phsft-bot

Copy link
Copy Markdown

Build failed on mac11.0/cxx17.
Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-26T21:21:25.515Z] CMake Error at /Users/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1045 (message):

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Errors:

  • [2021-07-26T21:26:40.981Z] CMake Error at /data/sftnight/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1045 (message):

@phsft-bot

Copy link
Copy Markdown

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2021-07-26T21:28:56.743Z] CMake Error at C:/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1045 (message):

@phsft-bot

Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot

Copy link
Copy Markdown

@weliveindetail

Copy link
Copy Markdown
Contributor

FYI: You might want to check -Bsymbolic-non-weak-functions in the future as well. It keeps the weird ELF interposition behavior for weak symbols, which can be vital for things like emulated TLS (see last comment in the review). Initial support comes with the current LLD 13 release: https://reviews.llvm.org/D102570#2915489

@Axel-Naumann Axel-Naumann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just a tiny comment and we should be good to merge

Comment thread interpreter/CMakeLists.txt
@Axel-Naumann

Copy link
Copy Markdown
Member

@weliveindetail thanks for the info, we will revisit this once -Bsymbolic-non-weak-functions becomes mainstream.

grasph and others added 6 commits August 24, 2021 11:44
…s resolved internally

This is expected to solve conflicts when interfacing with other software using LLVM, like Julia. See JuliaHEP/ROOT.jl#17 (comment)
…s resolved internally

This is expected to solve conflicts when interfacing with other software using LLVM, like Julia. See JuliaHEP/ROOT.jl#17 (comment)
Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch>
@grasph grasph force-pushed the llvm-conflict-fix branch from 50483c3 to 2ee441c Compare August 24, 2021 09:49
@oschulz

oschulz commented Oct 1, 2021

Copy link
Copy Markdown

Thanks a lot for this @grasph !

@Axel-Naumann

Copy link
Copy Markdown
Member

@phsft-bot build

@phsft-bot

Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@Axel-Naumann

Copy link
Copy Markdown
Member

macOS 12 messes up some system lib's internal (?) llvm symbols with those of cling: CommandLine Error: Option 'h' registered more than once!. Does anyone know why the default namespacing on macOS might fail here? I bet we're missing a similar flag now also for macOS :-/

@phsft-bot

Copy link
Copy Markdown

Build failed on mac1014/python3.
Running on macphsft17.dyndns.cern.ch:/build/jenkins/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot

Copy link
Copy Markdown

Build failed on mac11.0/cxx17.
Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@Axel-Naumann

Copy link
Copy Markdown
Member

Failures are unrelated. Thanks for the contribution!

@Axel-Naumann Axel-Naumann merged commit 1dd4734 into root-project:master Nov 4, 2021
@oschulz

oschulz commented Nov 4, 2021

Copy link
Copy Markdown

Which future ROOT release will this (likely) be included in?

@grasph

grasph commented Nov 4, 2021

Copy link
Copy Markdown
Contributor Author

Which future ROOT release will this (likely) be included in?

Hello @oschulz , I let Axel answer to your release question.

I expect you are interested by the interfacing with Julia. This is already working starting from version 6.24/02 (explained in a previous comment of the PR discussion).

This pull request is only consolidating a code correction which was included in the release between 6.24/00 and 6.24/02).

Philippe.

@oschulz

oschulz commented Nov 4, 2021

Copy link
Copy Markdown

I expect you are interested by the interfacing with Julia.

Yes - thanks @grasph !

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.

9 participants