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

LLVMlto library does not build on Linux (amd64) #1427

Closed
chandlerc opened this issue Dec 16, 2006 · 12 comments
Closed

LLVMlto library does not build on Linux (amd64) #1427

chandlerc opened this issue Dec 16, 2006 · 12 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla build-problem

Comments

@chandlerc
Copy link
Member

Bugzilla Link 1055
Resolution FIXED
Resolved on Feb 22, 2010 12:42
Version trunk
OS Linux

Extended Description

The library LLVMlto is only built on Darwin. Commenting out lines 26 and 28 of
tools/Makefile, to add lto to the build, results in the following error:

...
make[2]: Entering directory `/home/chandlerc/code/compilers/build/llvm/tools/lto'
llvm[2]: Linking Debug Loadable Module LLVMlto.so

*** Warning: Linking the shared library
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMlto.la against the
non-libtool
*** objects /home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMARM.o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMIA64.o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMAlpha.o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMPowerPC.o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMSparc.o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMX86.o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMCBackend.o is not portable!
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/bin/ld:
/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMARM.o: relocation
R_X86_64_32 against llvm::SupportDwarfLinkVar' can not be used when making a shared object; recompile with -fPIC /home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMARM.o: could not read symbols: Bad value collect2: ld returned 1 exit status make[2]: *** [/home/chandlerc/code/compilers/build/llvm/Debug/lib/LLVMlto.la] Error 1 make[2]: Leaving directory /home/chandlerc/code/compilers/build/llvm/tools/lto'
...

The same error is generated using './configure --with-pic' and without.

I am running Gentoo Linux, amd64 architecture, gcc (GCC) 4.1.1 (Gentoo 4.1.1-r3)
.

-Chandler

@chandlerc
Copy link
Member Author

assigned to @chandlerc

@lattner
Copy link
Collaborator

lattner commented Dec 16, 2006

This is because all of LLVM needs to be built PIC to link liblto. We should probably just do this.

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 17, 2006

An --enable-pic option to configure has been added. Chandler is going to try it
out to see if it resolves the problem. The option default to disabled so it
shouldn't affect anyone. When it works, we'll enable it as the default.

@lattner
Copy link
Collaborator

lattner commented Dec 17, 2006

Sounds good, when we know it works, we should just enable it by default everywhere. The pain of
building everything multiple times and supporting multiple configurations is far too high to justify
supporting partial pic or any other things. PIC everywhere is goodness :)

@chandlerc
Copy link
Member Author

Well, the -fPIC option seems to work, but isn't sufficient to solve this
problem. The libs themselves are being linked as static libraries, and can't be
pulled into a shared object. What we need is the split-generation of best static
libs and shared libs so that each can be linked as they are needed (I think?).

As a side note, I feel like when I was using a pure GNU autotools build system
it had an "ok" way of handling this. Ideally, each object is built with -fPIC,
and then two libs are linked, to minimize redundant operations. As a potential
refinement of the -fPIC behavior, as there are small speed gains without it,
perhaps allow building both PIC and non-PIC versions for everything, but only
when optimizations / release builds are enabled. Might allow the halved build
time during development (debugging) builds, but still provide performance gains
in releases, etc. Just a thought.

-Chandler

@chandlerc
Copy link
Member Author

Ok, I've been setting SHARED_LIBRARY=1 in Makefiles of the various objects that
cause errors when attempting to link LLVMlto, in order to get shared object
versions of those libs. So far, it seems to be removing libraries from the list
of errors, but I hit this snag with LLVMX86:

g++ -shared -nostdlib
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtbeginS.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86ATTAsmPrinter.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86AsmPrinter.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86CodeEmitter.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86ELFWriter.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86FloatingPoint.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86ISelDAGToDAG.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86ISelLowering.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86InstrInfo.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86IntelAsmPrinter.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86JITInfo.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86RegisterInfo.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86Subtarget.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86TargetAsmInfo.o
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86TargetMachine.o
-L/home/chandlerc/code/compilers/build/llvm/Debug/lib
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/lib
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../.. -lstdc++ -lm -lc -lgcc_s
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/crtendS.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../lib64/crtn.o -Wl,-soname
-Wl,libLLVMX86.so.0 -o
/home/chandlerc/code/compilers/build/llvm/Debug/lib/.libs/libLLVMX86.so.0.0.0
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/bin/ld:
/home/chandlerc/code/compilers/build/llvm/lib/Target/X86/Debug/.libs/X86JITInfo.o:
relocation R_X86_64_PC32 against `X86CompilationCallback2' can not be used when
making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../x86_64-pc-linux-gnu/bin/ld:
final link failed: Bad value
collect2: ld returned 1 exit status

-Chandler

@chandlerc
Copy link
Member Author

Patch builds LLVMlto as a static library
This doesn't build LLVMlto in the same manner in linux as it does on darwin.
Getting the build scripts to be able to do this in a reasonable manner (i.e.,
without building every file twice) isn't reasonable at this time. As a
compromise for the short term, we just build it as a static library when not in
Darwin.

@chandlerc
Copy link
Member Author

Patch to build LLVMlto on non Darwin systems
This is an update to fix a bug that shows up with compilers on other systems.
Particularly, while the library compiles without error, without an (empty)
definition of ~LinkTimeOptimizer(), some compilers (gcc 4.0.3) will throw an
error when linking it into a program.

@lattner
Copy link
Collaborator

lattner commented Jan 7, 2007

Reid: can you review the makefile changes please?

-Chris

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 7, 2007

Makefile changes look fine to me. Much of this was worked out between Chanderl
and I on IRC.

@lattner
Copy link
Collaborator

lattner commented Jan 8, 2007

When you have cvs commit access, please apply this Chandler!

@chandlerc
Copy link
Member Author

Committed patch.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla build-problem
Projects
None yet
Development

No branches or pull requests

3 participants