LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 13144 - opt should not be stripped during installation
Summary: opt should not be stripped during installation
Status: NEW
Alias: None
Product: tools
Classification: Unclassified
Component: opt (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-19 03:24 PDT by Carlos Sánchez de La Lama
Modified: 2012-08-30 12:23 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Sánchez de La Lama 2012-06-19 03:24:06 PDT
'opt' is stripped in Release builds, but this causes removals of some symbols which can be needed by loaded plugins. In a dynamic build of LLVM this is not a problem but in static builds this might prevent plugin usage. Plugins themselves cannot be statically linked with LLVM libs as this will cause duplicate symbols when loading them into 'opt'.

Solution is not to strip 'opt' in any case (KEEP_SYMBOLS := 1).

I sent a mail to llvmdev about this: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-June/050689.html
Comment 1 Ben Ransford 2012-08-29 10:35:09 PDT
I see that this problem persists in ToT.  Perhaps it bites only those of us who try to dynamically load our own pass libraries under Darwin?
Comment 2 Duncan Sands 2012-08-29 10:36:53 PDT
I never had any problems on linux.
Comment 3 Ben Ransford 2012-08-29 10:42:21 PDT
(In reply to comment #2)
> I never had any problems on linux.

Me either, but I'm writing a cross-platform set of passes that I don't want to try to fold into mainline (they're too specialized to a specific domain).  Optimization passes as shared libraries are an awesome idea.

I guess the objection would be that KEEP_SYMBOLS would make the opt executable too big?
Comment 4 Duncan Sands 2012-08-29 14:29:05 PDT
Well, I'm kind of worried that this is a bandaid, and that the fundamental
problem hasn't been understood.
Comment 5 Carlos Sánchez de La Lama 2012-08-30 01:17:19 PDT
I do not think this problem is linux-specific, but AFAIR linux builds are shared by default, thus the problem does not show there. For some reason, Darwin builds are static (but can be --enable-shared).

The fundamental problem as I see it is that dynamically loading modules into a statically-build opt (or any other tool for the matter) might not work. Example:

libLLVMxxx.a defines global symbol G.
opt links against libLLVMxxx.a links to use G.
opt is stripped (G is no longer visible in opt).

test_module.so uses G, so it links against libLLVMxxx.a. Now, when opt loads test_module.so, module's "G" is not the same as opt "G", which it should be as it is a global symbol. It will not give duplicated symbols error because opt symbols were stripped, but it might not work properly.

My proposal is not to strip opt, therefore the modules do not need to be linked because "opt" will have all the required symbols. This effectively bundles a shared library containing all LLVM symbols into opt. I do not think there is another way of allowing module loading reliably.

Another option is entirely disabling module loading in opt for static builds.
Comment 6 Duncan Sands 2012-08-30 01:44:45 PDT
On linux opt is also statically linked with the LLVM libraries by default.
Comment 7 Carlos Sánchez de La Lama 2012-08-30 01:48:37 PDT
(In reply to comment #6)
> On linux opt is also statically linked with the LLVM libraries by default.

Ok, I remembered otherwise, haven't build LLVM on linux for a while.

Strange that the problem does not show, then. Are you linking your modules statically against LLVM libraries?
Comment 8 Carlos Sánchez de La Lama 2012-08-30 12:23:05 PDT
I have seen this happening with different symbols, but the actual symbol giving problems when I reported the bug can be seen here:

http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-June/050689.html

in point 1).

so, '__ZN4llvm10ModulePass17assignPassManagerERNS_7PMStackENS_15PassManagerTypeE'.

Probably it was not only this one, I would need to replicate the scenario to be sure (now I got a  LLVM built with KEEP_SYMBOLS in opt and with gcc instead of clang to avoid the second problem I stated in the mail).