[OpenWrt-Devel] STAGING_DIR vs. --sysroot

Felix Fietkau nbd at openwrt.org
Fri Nov 6 09:48:17 EST 2015


On 2015-11-06 15:24, Rüdiger, Christoph wrote:
> Hi folks,
> 
> I'm wondering a bit why the OpenWrt toolchains rely on a set
> STAGING_DIR environment variable. I haven't found any documentation on
> this except "You have to set it". Examining the source tree of gcc
> didn't show me any STAGING_DIR occurrence. It seems to be used only in
> the specs file. And from examining these, I get the feeling that the
> STAGING_DIR environment variable is used to work around or against the
> sysroot setting.
> 
> As the OpenWrt SDK is the first gcc I've worked with that rely on a
> command line variable, my question is: Why did OpenWrt introduced this
> (uncommon?) extension instead of an additional command line argument?
Our use of the extra variable comes from the fact that we separate the
toolchain path from the path where packages install their headers and
library files. I think most other build systems don't do that.

I think if we were to override the sysroot and set it to
$STAGING_DIR/usr, gcc would probably not find the include files from
$TOOLCHAIN_DIR anymore.

For testing, I just removed the specs file override and tried to build a
normal binary with sysroot pointing to $STAGING_DIR, and it did not even
find the header files from there.

> The STAGING_DIR env variable makes it difficult to work with in
> build systems like cmake where you have to give a toolchain file with the
> compiler flags and paths and have to set the environment variable for
> each build.
I think most people don't bother with that and just use the normal
OpenWrt build system commands instead of running make in the package
build directories directly.

- Felix
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list