Closed d25fe0be closed 6 years ago
Oops, I forgot the flags --with-sysroot=/opt
, which may be specified when configure
ing GCC.
This flag (quoted from Installing GCC):
Tells GCC to consider dir as the root of a tree that contains (a subset of) the root filesystem of the target operating system. Target system headers, libraries and run-time object files will be searched for in there. More specifically, this acts as if --sysroot=dir was added to the default options of the built compiler. The specified directory is not copied into the install tree, unlike the options --with-headers and --with-libs that this option obsoletes. The default value, in case --with-sysroot is not given an argument, is ${gcc_tooldir}/sys-root. If the specified directory is a subdirectory of ${exec_prefix}, then it will be found relative to the GCC binaries if the installation tree is moved.
This option affects the system root for the compiler used to build target libraries (which runs on the build system) and the compiler newly installed with make install; it does not affect the compiler which is used to build GCC itself.
If you specify the --with-native-system-header-dir=dirname option then the compiler will search that directory within dirname for native system headers rather than the default /usr/include.
And this seems to be more suitable for our use. (As we install everything to /opt
.)
Fixed with https://github.com/Entware-for-kernel-3x/entware-packages-3x/blob/master/devel/gcc/Makefile#L117 (thanks for PR). This will be also in Entware-ng soon
Package: GCC
For existing package:
-Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3
should be automatically added when invokingld
.Platform:
Analysis:
Entware-ng's GCC is compiled with
--with-stage1-ldflags='-Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3' --with-boot-ldflags='static-libstdc++ -static-libgcc -Wl,-rpath=/opt/lib -Wl,--dynamic-linker=/opt/lib/ld-linux.so.3'
, but IIUC, according to Installing GCC, none of these parameters affects GCC's behavior when compiling user's code.I also noted there's a script
gcc-env.sh
in/opt/bin/
, but apparently that does not affect GCC (when called directly, not throughMakefile
or something alike) either. GCC itself does not honor these flags IIRC.I suggest that we could put a
specs
file, generated bygcc -dumpspecs
, in/opt/lib/gcc/arm-openwrt-linux-gnueabi/6.3.0
, and modify the line below*link:
:/lib/ld-linux.so.3
with/opt/lib/ld-linux.so.3
(there're multiple occurrences.),-rpath /opt/lib
.IMHO
gcc_env.sh
could also be deprecated once we've done this.There's still a caveat I'm unable to address right now though: In this way the
rpath
we set will take precedence over users' (if any), and that's bad.