[SERVER-51244] Evaluate linker argument before testing compiler Created: 30/Sep/20  Updated: 29/Oct/23  Resolved: 01/Oct/20

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: 4.8.0

Type: Bug Priority: Major - P3
Reporter: Spencer Jackson Assignee: Daniel Moody
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-49465 Builds with -fuse-ld=bfd fail in --li... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Sprint: Dev Platform 2020-10-05
Participants:

 Description   

Prior to SERVER-49465, developers explicitly configured SCons to use a particular linker by definining fuse-ld=<linker> in the LINKFLAGS. Now, they use -linker=<linker>. The linker argument is evaluated after some configure checks, such as Checking that the C++ compiler can link a C++ program... have been performed. This means that if LINKFLAGS are provided which depend on a particular linker, the compiler link test will fail.

Before SERVER-49465, the following configuration worked:

python ./buildscripts/scons.py --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --link-model=dynamic --build-tools=next --ninja generate-ninja ICECC=icecc CCACHE=ccache CCFLAGS="-Wa,--compress-debug-sections -gsplit-dwarf -fvisibility-inlines-hidden" LINKFLAGS="-Wl,-O2 -Wl,--icf=safe -fuse-ld=lld -Wl,--hash-style=gnu -Wl,-Bsymbolic-functions" MONGO_VERSION="0.0.0" MONGO_GIT_HASH="unknown"

Attempting to replace fuse-ld=lld with -linker=lld results in the following:

(python3-venv) ubuntu@ip-10-122-6-169:~/mongo$ autoninja
scons: Reading SConscript files ...
scons: running with args /home/ubuntu/mongo/python3-venv/bin/python ./buildscripts/scons.py --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --link-model=dynamic --build-tools=next --ninja generate-ninja ICECC=icecc CCACHE=ccache CCFLAGS=-Wa,--compress-debug-sections -gsplit-dwarf -fvisibility-inlines-hidden --linker=lld LINKFLAGS=-Wl,-O2 -Wl,--icf=safe -Wl,--hash-style=gnu -Wl,-Bsymbolic-functions MONGO_VERSION=0.0.0 MONGO_GIT_HASH=unknown
Using variable customization file etc/scons/mongodbtoolchain_v3_clang.vars
scons version: 3.1.2
python version: 3 7 0 'final' 0
CC is /opt/mongodbtoolchain/v3/bin/clang
/opt/mongodbtoolchain/v3/bin/clang resolves to /opt/mongodbtoolchain/revisions/e5348beb43e147b74a40f4ca5fb05a330ea646cf/stow/llvm-v3.99u/bin/clang-7
CXX is /opt/mongodbtoolchain/v3/bin/clang++
/opt/mongodbtoolchain/v3/bin/clang++ resolves to /opt/mongodbtoolchain/revisions/e5348beb43e147b74a40f4ca5fb05a330ea646cf/stow/llvm-v3.99u/bin/clang-7
Checking whether the C compiler works... (cached) yes
Checking whether the C++ compiler works... (cached) yes
Checking that the C++ compiler can link a C++ program... no
C++ compiler /opt/mongodbtoolchain/v3/bin/clang++ can't link C++ programs
See /home/ubuntu/mongo/build/scons/config.log for details

/opt/mongodbtoolchain/v3/bin/clang++ -o build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0_a328baf5669f1d30a6b15100081d56ea -Wl,-O2 -Wl,--icf=safe -Wl,--hash-style=gnu -Wl,-Bsymbolic-functions build/scons/opt/sconf_temp/conftest_ac30bfea77045c1c67c4f51773b51414_0.o
/opt/mongodbtoolchain/v3/bin/ld: unrecognized option '--icf=safe'
/opt/mongodbtoolchain/v3/bin/ld: use the --help option for usage information
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
scons: Configure: no



 Comments   
Comment by Githook User [ 01/Oct/20 ]

Author:

{'name': 'Daniel Moody', 'email': 'daniel.moody@mongodb.com', 'username': 'dmoody256'}

Message: SERVER-51244 Moved configure checks around so that linker-ld option is processed early
Branch: master
https://github.com/mongodb/mongo/commit/a9ad661dc113fe44aecfcac23f6df8c7be087462

Generated at Thu Feb 08 05:24:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.