[PATCH] Fix the --enable-shared build

Rafael Espíndola rafael.espindola at gmail.com
Sun Jun 29 16:17:42 PDT 2014


Yes, it looks like a bug in gcc.Given the attached testcase gcc 4.9
will produce an undefined reference to
_ZNK4llvm2cl6parserIPKNS_8PassInfoEE9getOptionEj.

I will try to report a bug after dinner.


On 29 June 2014 18:34, Chandler Carruth <chandlerc at google.com> wrote:
> I'm suspicious of a bug here. At least at first, I don't see why the code
> as-is wouldn't work.
>
> My best guess is that (either way) it stems from the oddities of PassInfo
> and it being included *after* other headers weirdly. The technique in the
> patch to delay instantiation until the .cpp file seems a reasonable way to
> work around the problem, whatever it is...
>
>
> On Sun, Jun 29, 2014 at 2:19 PM, Rafael Espíndola
> <rafael.espindola at gmail.com> wrote:
>>
>> I was able to reproduce this. Checking if it is a bug in gcc 4.9 or in our
>> code.
>>
>> On 25 June 2014 23:22, Sanjoy Das <sanjoy at playingwithpointers.com> wrote:
>> > Hi Rafael,
>> >
>> > I get the build failure when building with g++ 4.9.0.  This is how I
>> > build:
>> >
>> > "CXX=g++  ../configure --enable-optimized --enable-shared
>> > --enable-targets=host && make -j60"
>> >
>> > I haven't tried building with clang yet -- if you can successfully
>> > build with clang then it could be an issue specific to gcc.  This is
>> > the failure I get:
>> >
>> > [snip]
>> >
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-nm'
>> > llvm[2]: Linking Release+Asserts executable llvm-symbolizer (without
>> > symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable
>> > llvm-symbolizer (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-symbolizer'
>> > llvm[2]: Linking Release+Asserts executable llvm-size (without symbols)
>> > llvm[2]: Linking Release+Asserts executable obj2yaml (without symbols)
>> > llvm[2]: Linking Release+Asserts executable llvm-stress (without
>> > symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable llvm-size
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-size'
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable obj2yaml
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/obj2yaml'
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable
>> > llvm-stress (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-stress'
>> > llvm[2]: Linking Release+Asserts executable llvm-diff (without symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable llvm-diff
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-diff'
>> > llvm[2]: Linking Release+Asserts executable llvm-mc (without symbols)
>> > llvm[2]: Linking Release+Asserts Shared Library libLTO.so
>> > llvm[2]: Building Release+Asserts Archive Library libLTO.a
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable llvm-mc
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-mc'
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/lto'
>> > llvm[2]: Linking Release+Asserts executable lli (without symbols)
>> > llvm[2]: Linking Release+Asserts executable llc (without symbols)
>> > make[2]: Entering directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-lto'
>> > llvm[2]: Compiling llvm-lto.cpp for Release+Asserts build
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable llc
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llc'
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable lli
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/lli'
>> > llvm[2]: Linking Release+Asserts executable bugpoint (without symbols)
>> >
>> > /home/sanjoy/work/llvm.git/build.fastdebug/tools/bugpoint/Release+Asserts/bugpoint.o:
>> > In function `llvm::cl::list<llvm::PassInfo const*, bool,
>> > llvm::PassNameParser>::getExtraOptionNames(llvm::SmallVectorImpl<char
>> > const*>&)':
>> >
>> > bugpoint.cpp:(.text._ZN4llvm2cl4listIPKNS_8PassInfoEbNS_14PassNameParserEE19getExtraOptionNamesERNS_15SmallVectorImplIPKcEE[_ZN4llvm2cl4listIPKNS_8PassInfoEbNS_14PassNameParserEE19getExtraOptionNamesERNS_15SmallVectorImplIPKcEE]+0x76):
>> > undefined reference to `llvm::cl::parser<llvm::PassInfo
>> > const*>::getOption(unsigned int) const'
>> > collect2: error: ld returned 1 exit status
>> > make[2]: ***
>> > [/home/sanjoy/work/llvm.git/build.fastdebug/Release+Asserts/bin/bugpoint]
>> > Error 1
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/bugpoint'
>> > make[1]: *** [bugpoint/.makeall] Error 2
>> > make[1]: *** Waiting for unfinished jobs....
>> > llvm[2]: Linking Release+Asserts executable llvm-objdump (without
>> > symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable
>> > llvm-objdump (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-objdump'
>> > llvm[2]: Linking Release+Asserts executable yaml2obj (without symbols)
>> > llvm[2]: Linking Release+Asserts executable opt (without symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable yaml2obj
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/yaml2obj'
>> >
>> > /home/sanjoy/work/llvm.git/build.fastdebug/tools/opt/Release+Asserts/opt.o:
>> > In function `llvm::cl::list<llvm::PassInfo const*, bool,
>> > llvm::PassNameParser>::getExtraOptionNames(llvm::SmallVectorImpl<char
>> > const*>&)':
>> >
>> > opt.cpp:(.text._ZN4llvm2cl4listIPKNS_8PassInfoEbNS_14PassNameParserEE19getExtraOptionNamesERNS_15SmallVectorImplIPKcEE[_ZN4llvm2cl4listIPKNS_8PassInfoEbNS_14PassNameParserEE19getExtraOptionNamesERNS_15SmallVectorImplIPKcEE]+0x56):
>> > undefined reference to `llvm::cl::parser<llvm::PassInfo
>> > const*>::getOption(unsigned int) const'
>> > collect2: error: ld returned 1 exit status
>> > make[2]: ***
>> > [/home/sanjoy/work/llvm.git/build.fastdebug/Release+Asserts/bin/opt]
>> > Error 1
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/opt'
>> > make[1]: *** [opt/.makeall] Error 2
>> > llvm[2]: Linking Release+Asserts executable llvm-readobj (without
>> > symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable
>> > llvm-readobj (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-readobj'
>> > llvm[2]: Linking Release+Asserts executable llvm-lto (without symbols)
>> > llvm[2]: ======= Finished Linking Release+Asserts Executable llvm-lto
>> > (without symbols)
>> > make[2]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools/llvm-lto'
>> > make[1]: Leaving directory
>> > `/home/sanjoy/work/llvm.git/build.fastdebug/tools'
>> > make: *** [all] Error 1
>> >
>> >
>> > On Tue, Jun 24, 2014 at 7:29 AM, Rafael Espíndola
>> > <rafael.espindola at gmail.com> wrote:
>> >> I can't reproduce the problem. Which file has the undefined symbol?
>> >> Maybe it is just missing an include?
>> >>
>> >> On 19 June 2014 19:00, Sanjoy Das <sanjoy at playingwithpointers.com>
>> >> wrote:
>> >>> The shared-object build for llvm (i.e. libLLVM-3.5svn.so + tools)
>> >>> currently breaks on linux when linking opt.  This patch is an attempt
>> >>> to fix that.
>> >>>
>> >>> -- Sanjoy
>> >>>
>> >>> _______________________________________________
>> >>> llvm-commits mailing list
>> >>> llvm-commits at cs.uiuc.edu
>> >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bugpoint.ii
Type: application/octet-stream
Size: 657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140629/e36fcb5e/attachment.obj>


More information about the llvm-commits mailing list