[SERVER-31439] scons cannot find custom compiler and linker Created: 06/Oct/17  Updated: 27/Oct/23  Resolved: 09/Oct/17

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

Type: Question Priority: Major - P3
Reporter: Chan Lewis Assignee: Andrew Morrow (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

I work on centos 6.8. gcc 5.3 and binutilus is not installed in the standard path. When I use scons, it show:
??scons: Reading SConscript files ...
scons version: 3.0.0
python version: 2 7 11 'final' 0
Checking whether the C compiler works... yes
Checking whether the C++ compiler works... yes
Checking that the C++ compiler can link a C++ program... yes
Checking if C++ compiler "g++" is GCC... yes
Checking if C compiler "gcc" is GCC... yes
Detected a x86_64 processor
Checking if target OS linux is supported by the toolchain... yes
Checking if C compiler is GCC 5.3.0 or newer...no
Checking if C++ compiler is GCC 5.3.0 or newer...no
ERROR: Refusing to build with compiler that does not meet requirements
See /root/coding/mongo-master/build/scons/config.log for details??

And If I add CC and CXX option to scons, it will find the gcc/g++, but still cannot find corrresonding custom as and ld (system as and ld cannot work).

Please help, how can add custom linker to scons ?



 Comments   
Comment by Andrew Morrow (Inactive) [ 09/Oct/17 ]

I'm going to close out this ticket because I don't believe there is additional work indicated for us to do. If you continue to have problems, please feel free to reach out on the mongodb-user or mongodb-dev groups, which I monitor. Or, if you prefer to stay in JIRA, just comment on this ticket and I will see your reply.

Comment by Chan Lewis [ 08/Oct/17 ]

Thanks. I'll dig into that.

Comment by Andrew Morrow (Inactive) [ 07/Oct/17 ]

A correctly configured toolchain should know where to look for the linker it was told to build against at configure time. You shouldn't need to set the path. However, you might find the following incantation useful:

scons --variables-files=etc/scons/propagate_shell_environment.vars

This will propagate your shell environment including PATH into all processes spawned by SCons. However, I do suggest that you look into why your toolchain seems to be misbehaving.

Comment by Chan Lewis [ 07/Oct/17 ]

I suspect it has something to do with this why-doesnt-scons-find-my-compilerlinkeretc-i-can-execute-it-just-fine-from-the-command-line. But SConstrut in the root directory is a little complicated to me, I still don't know where to add statement to support external PATH.

Comment by Chan Lewis [ 07/Oct/17 ]

Here's the result:

/data/software/gcc-5.3.0/bin/g++ -o build/scons/opt/sconf_temp/conftest_2 build/scons/opt/sconf_temp/conftest_2.o
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
root@mongo-master (master *)$ export PATH=/data/software/binutils-2.26/bin:$PATH
root@mongo-master (master *)$ /data/software/gcc-5.3.0/bin/g++ -o build/scons/opt/sconf_temp/conftest_2 build/scons/opt/sconf_temp/conftest_2.o

Obviously after I add the binutilus/bin to PATH, it'll build ok. So the problem seems that scons doesn't use my ld even though binutilus/bin is in the PATH.

Comment by Andrew Morrow (Inactive) [ 06/Oct/17 ]

Are you sure your toolchain in /data/software was configured correctly? What does

/data/software/gcc-5.3.0/bin/g++ -o build/scons/opt/sconf_temp/conftest_2 build/scons/opt/sconf_temp/conftest_2.o -###

Print?

Comment by Chan Lewis [ 06/Oct/17 ]

part of config.log is :

/data/software/gcc-5.3.0/bin/g++ -o build/scons/opt/sconf_temp/conftest_2 build/scons/opt/sconf_temp/conftest_2.o
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
scons: Configure: no

Obvisouly it still use the system ld

Comment by Chan Lewis [ 06/Oct/17 ]

I try to add this to SConstruct, but it seems not be working.

env = Environment(ENV =

{'PATH' : os.environ['PATH']}

)

Generated at Thu Feb 08 04:27:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.