bfgroup / b2

B2 makes it easy to build C++ projects, everywhere.
https://www.bfgroup.xyz/b2/
Boost Software License 1.0
75 stars 228 forks source link

Linking Fails - dangerous relocation: R_AMD64_IMAGEBASE with __ImageBase undefined #382

Closed pixel27 closed 3 months ago

pixel27 commented 4 months ago

Make sure you completed the following tasks

Environment and version details

I can't compile b2. I'm not sure where else to go to diagnose/fix this issue.

Brief problem description

Running bootstrap.sh fails at the linking step.

Steps to reproduce the issue

./bootstrap.sh

Actual behavior summary

$ ./bootstrap.sh
Building B2 engine..

###
###
### Using 'gcc' toolset.
###
###

g++ (Gentoo 13.2.1_p20240210 p14) 13.2.1 20240210
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

###
###

> windres --input res.rc --output res.o
> g++ -x c++ -std=c++11 -pthread -O2 -s -DNDEBUG -Wl,res.o bindjam.cpp builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filent.cpp filesys.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp tasks.cpp timestamp.cpp value.cpp variable.cpp w32_getreg.cpp mod_jam_builtin.cpp mod_jam_class.cpp mod_jam_errors.cpp mod_jam_modules.cpp mod_order.cpp mod_path.cpp mod_property_set.cpp mod_regex.cpp mod_sequence.cpp mod_set.cpp mod_string.cpp mod_summary.cpp mod_sysinfo.cpp mod_version.cpp -o b2
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: warning: res.o: missing .note.GNU-stack section implies executable stack
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
res.o:(.rsrc$01+0x48): dangerous relocation: R_AMD64_IMAGEBASE with __ImageBase undefined
collect2: error: ld returned 1 exit status

Failed to build B2 build engine

Expected behavior summary

The b2 build engine should build correctly.

Kojoley commented 4 months ago

I though this might happen, but in my mind windres can only appear in the PATH when g++ is also from MinGW. How you end up with a system like yours?

You may workaround the issue with B2_DONT_EMBED_MANIFEST=1 ./bootstrap.sh.

pixel27 commented 3 months ago

B2_DONT_EMBED_MANIFEST=1 ./bootstrap.sh worked, thank you.

I don't think my system is that customized, I do have gcc and clang in the path, but I shouldn't have MinGW since I'm running Linux. So no clue whats happening.