Skip to content

[cmake,cling] Hide C and C++ symbols alike:#4689

Merged
Axel-Naumann merged 1 commit intoroot-project:masterfrom
Axel-Naumann:llvm-hide-all-symbols
Dec 17, 2019
Merged

[cmake,cling] Hide C and C++ symbols alike:#4689
Axel-Naumann merged 1 commit intoroot-project:masterfrom
Axel-Naumann:llvm-hide-all-symbols

Conversation

@Axel-Naumann
Copy link
Copy Markdown
Member

We had symbols exposed, which in turn meant symbols were resolved by the dynamic loader,
which in turn meant another libllvm.so could interfere with those of cling. By hiding these
symbols, all symbols are self-contained and not external symbols leak into libCling.

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-performance-centos7-multicore/default.
See console output.

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-fedora29/python3.
See console output.

Errors:

  • FAILED: tutorials/hsimple.root

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-fedora30/cxx14.
See console output.

Errors:

  • FAILED: tutorials/hsimple.root

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-fedora27/noimt.
See console output.

Errors:

  • FAILED: tutorials/hsimple.root

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-ubuntu16/nortcxxmod.
See console output.

Errors:

  • FAILED: cd /mnt/build/workspace/root-pullrequests-build/build/tutorials && LD_LIBRARY_PATH=/mnt/build/workspace/root-pullrequests-build/build/lib: ROOTIGNOREPREFIX=1 ROOT_HIST=0 /mnt/build/workspace/root-pullrequests-build/build/bin/root.exe -l -q -b -n -x hsimple.C -e return

We had symbols exposed, which in turn meant symbols were resolved by the dynamic loader,
which in turn meant another libllvm.so could interfere with those of cling. By hiding these
symbols, all symbols are self-contained and not external symbols leak into libCling.
cling needs to resolve its own symbols, so unhide those.
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14
How to customize builds

@Axel-Naumann
Copy link
Copy Markdown
Member Author

@davidrohr let me know whether this fixes also your case.

@davidrohr
Copy link
Copy Markdown

davidrohr commented Dec 13, 2019 via email

@davidrohr
Copy link
Copy Markdown

@Axel-Naumann : I think this patch is correct in any case, since the symbols should be hidden.
Unfortunately, it is not enough to solve our problem. My test case from #4668 still yields:

Error in <UnknownClass::InitInterpreter()>: LLVM SYMBOLS ARE EXPOSED TO CLING! This will cause problems; please hide them or dlopen() them after the call to TROOT::InitInterpreter()!
: CommandLine Error: Option 'version' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
  • The first line LLVM SYMBOLS ARE EXPOSED.... is because the check in core/base/src/TROOT.cxx is not disabled, so this this is irrelevant. In fact, if your patch would work, this check should be removed.
  • The second error ... inconsistency in registered.... however is the same problem we saw before, with the 2 LLVM instances clashing.

@Axel-Naumann
Copy link
Copy Markdown
Member Author

@davidrohr :

The second error ... inconsistency in registered.... however is the same problem we saw before, with the 2 LLVM instances clashing.

Damn. I tried with LD_PRELOADing libllvm and that worked with this PR, and failed without this PR. Can you come up with a reproducer for what you see?

I'll merge this nonetheless.

@davidrohr
Copy link
Copy Markdown

Can you come up with a reproducer for what you see?

@Axel-Naumann : The following simple test case

#include <TROOT.h>
int main(int argc, char** argv) {
  gROOT->GetInterpreter();
  return 0;
}

compiled via
c++ -o test -O0 -ggdb root-config --libs -Iroot-config --incdir -std=c++17 test.cpp /usr/lib64/libgandiva.so
yields the error for me. I have a system installation of arrow with gandiva. If I remove the libgandiva.so from the command line, it works fine.

@davidrohr
Copy link
Copy Markdown

Damn. I tried with LD_PRELOADing libllvm and that worked with this PR, and failed without this PR.

Damn, that is weird. Should be the same as linking to libgandiva. I'll try that on my setup to double-check.

@Axel-Naumann Axel-Naumann merged commit 08e767c into root-project:master Dec 17, 2019
@Axel-Naumann Axel-Naumann deleted the llvm-hide-all-symbols branch December 17, 2019 15:54
@davidrohr
Copy link
Copy Markdown

@Axel-Naumann : I have rebuilt ROOT from scratch and attempted my above test case with

LD_PRELOAD=/usr/lib64/libgandiva.so ./test

which still gives me the same error:

Error in <UnknownClass::InitInterpreter()>: LLVM SYMBOLS ARE EXPOSED TO CLING! This will cause problems; please hide them or dlopen() them after the call to TROOT::InitInterpreter()!
: CommandLine Error: Option 'version' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

Perhaps preloading individual LLVM libraries works, but with gandiva it certainly doesn't.
So unfortunately this patch is insufficient to solve my problem.

@davidrohr
Copy link
Copy Markdown

@Axel-Naumann : Did you have a chance to attempt the namespace hack we discussed, perhaps it has a better chance of solving the issue.

@davidrohr
Copy link
Copy Markdown

@Axel-Naumann : I have to admit I have been stupid and my last posts have been wrong.
I did built root without builtin_llvm, so this could not have worked by designed.
I have rebuilt now with builtin_llvm and with your patch, and now I am only getting the warning message

Error in <UnknownClass::InitInterpreter()>: LLVM SYMBOLS ARE EXPOSED TO CLING! This will cause problems; please hide them or dlopen() them after the call to TROOT::InitInterpreter()!

But this is clear, since ROOT just checks for the presence of the LLVM symbols.
I am now rebuilding the ALICE software with this ROOT and checking whether the segfaults are gone.

@davidrohr
Copy link
Copy Markdown

@Axel-Naumann : This patch is fully working for us. Thx a lot and sorry for the false information before.
Could you cherry-pick this to 6.18.00-patches?
In addition, the warning in https://github.com/root-project/root/blob/master/core/base/src/TROOT.cxx#2052 should be disabled, when ROOT is compiled with -DBUILTIN_LLVM. Otherwise it is misleading.

@Axel-Naumann
Copy link
Copy Markdown
Member Author

ACK on the warning, will take care after Jan 6.

@Axel-Naumann
Copy link
Copy Markdown
Member Author

Axel-Naumann commented Jan 7, 2020

Warning removal is in #4736 - I don't care too much about non-builtin llvm, people are on their own then.

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.

4 participants