Makefile: unset MAKEFLAGS
PATCH 1/1 Makefile: unset MAKEFLAGS
MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. To avoid this, unset the MAKEFLAGS environment variable.
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -207,6 +207,7 @@ unexport CFLAGS unexport CXXFLAGS unexport GREP_OPTIONS unexport CONFIG_SITE +unexport MAKEFLAGS unexport QMAKESPEC unexport TERMINFO
Signature · 1 line
1.8.3.2
PATCH 1/1 Makefile: unset MAKEFLAGS
Dear Samuel Martin,
Quoted 2 lines · Samuel Martin
MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. To avoid this, unset the MAKEFLAGS environment variable.
Does unsetting MAKEFLAGS really allows to prevent top-level parallel build on Buildroot? Or does it only prevents MAKEFLAGS from leaking to the sub-make calls that we do to build packages?
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 Makefile: unset MAKEFLAGS
Hi Thomas,
2013/7/7 Thomas Petazzoni <[email protected]>:
Quoted 8 lines
Dear Samuel Martin,
Quoted 2 lines · Samuel Martin
MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. To avoid this, unset the MAKEFLAGS environment variable.
Does unsetting MAKEFLAGS really allows to prevent top-level parallel build on Buildroot?
It does, but as Peter points out, this also disables some other options we don't want to see disabled.
So, forget about this patch.
Quoted 9 lines
Or does it only prevents MAKEFLAGS from leaking to the sub-make calls that we do to build packages?
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux development, consulting, training and support.
http://free-electrons.com
Signature · 1 line
Samuel
PATCH 1/1 Makefile: unset MAKEFLAGS
In reply to Samuel MartinQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
Samuel> MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. Samuel> To avoid this, unset the MAKEFLAGS environment variable.
Unfortunately this also drops '-s' from child make invocations, making silent builds significantly more noisy.
We have .NOTPARALLEL: in the top level Makefile, isn't that enough to ensure funky MAKEFLAGS settings? Anything else you encountered?
Samuel> Signed-off-by: Samuel Martin <[email protected]> Samuel> ---
Samuel> Makefile | 1 +
Samuel> 1 file changed, 1 insertion(+)
Samuel> diff --git a/Makefile b/Makefile
Samuel> index 015fbdf..11a7b70 100644
Samuel> --- a/Makefile
Samuel> +++ b/Makefile
Samuel> @@ -207,6 +207,7 @@ unexport CFLAGS
Samuel> unexport CXXFLAGS Samuel> unexport GREP_OPTIONS Samuel> unexport CONFIG_SITE
Samuel> +unexport MAKEFLAGS
Samuel> unexport QMAKESPEC
Samuel> unexport TERMINFO
Samuel> --
Samuel> 1.8.3.2
Samuel> _______________________________________________ Samuel> buildroot mailing list
Samuel> buildroot at busybox.net
Samuel> http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 Makefile: unset MAKEFLAGS
Hi Peter,
2013/7/7 Peter Korsgaard <[email protected]>:
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Samuel" == Samuel Martin <[email protected]> writes:
Samuel> MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. Samuel> To avoid this, unset the MAKEFLAGS environment variable.
Unfortunately this also drops '-s' from child make invocations, making silent builds significantly more noisy.
We have .NOTPARALLEL: in the top level
Makefile, isn't that enough to ensure funky MAKEFLAGS settings? Anything else you encountered?
Seems not since, some days ago, some people complained about it on the irc channel.
I will update the doc, instead.
Signature · 1 line
Samuel
PATCH 1/1 Makefile: unset MAKEFLAGS
In reply to Samuel MartinHi,
Quoted 13 lines · Samuel Martin
MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. To avoid this, unset the MAKEFLAGS environment variable.
Signed-off-by Samuel Martin <[email protected]>--- Makefile | 1 + 1 file changed, 1 insertion(+)Makefile +0
-0
Makefile unexport CFLAGS · line 213
Quoted 7 lines
Makefile +1
-0@@ -207,6 +207,7 @@ unexport CFLAGS unexport CXXFLAGS unexport GREP_OPTIONS unexport CONFIG_SITE +unexport MAKEFLAGS unexport QMAKESPEC unexport TERMINFO
What is the strategy with respect to cleaning up the user's environment when building buildroot?
Because there are a number of other variables that users can have (and do have) that corrupt the build, for example:
C_INCLUDE_PATHCPLUS_INCLUDE_PATHLIBRARY_PATHLD_LIBRARY_PATH
PERL5LIBGCC_EXEC_PREFIX
In the twisted environments that I'm working in, I'm unsetting these from a wrapper around buildroot make. However, it seems that there already are a number of cleanups done inside buildroot itself, so it makes sense to add the above variables to the list.
What do you think?
Best regards,
Thomas
PATCH 1/1 Makefile: unset MAKEFLAGS
Quoted 36 lines · Thomas De Schampheleire
Hi,
Quoted 13 lines · Samuel Martin
MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. To avoid this, unset the MAKEFLAGS environment variable.
Signed-off-by Samuel Martin <[email protected]>--- Makefile | 1 + 1 file changed, 1 insertion(+)Makefile +0
-0Makefile unexport CFLAGS · line 213
Quoted 7 lines
Makefile +1
-0@@ -207,6 +207,7 @@ unexport CFLAGS unexport CXXFLAGS unexport GREP_OPTIONS unexport CONFIG_SITE +unexport MAKEFLAGS unexport QMAKESPEC unexport TERMINFOWhat is the strategy with respect to cleaning up the user's environment when building buildroot?
Because there are a number of other variables that users can have (and do have) that corrupt the build, for example:
C_INCLUDE_PATHCPLUS_INCLUDE_PATHLIBRARY_PATHLD_LIBRARY_PATH
PERL5LIBGCC_EXEC_PREFIX
Quoted 6 lines
In the twisted environments that I'm working in, I'm unsetting these from a wrapper around buildroot make. However, it seems that there already are a number of cleanups done inside buildroot itself, so it makes sense to add the above variables to the list.
What do you think?
How about going all the way: clean out the environment completely, and explicitly add env vars to builders as needed. That would result in a more deterministic build environment, IMHO.
Best regards,
Bj?rn Forsman
PATCH 1/1 Makefile: unset MAKEFLAGS
Hi Bj?rn,
Quoted 43 lines · Bj?rn Forsman
Quoted 41 lines · Thomas De Schampheleire
Hi,
Quoted 13 lines · Samuel Martin
MAKEFLAGS can carry options that make Buildroot failed, eg. '-jN'. To avoid this, unset the MAKEFLAGS environment variable.
Signed-off-by Samuel Martin <[email protected]>--- Makefile | 1 + 1 file changed, 1 insertion(+)Makefile +0
-0Makefile unexport CFLAGS · line 213
Quoted 7 lines
Makefile +1
-0@@ -207,6 +207,7 @@ unexport CFLAGS unexport CXXFLAGS unexport GREP_OPTIONS unexport CONFIG_SITE +unexport MAKEFLAGS unexport QMAKESPEC unexport TERMINFOWhat is the strategy with respect to cleaning up the user's environment when building buildroot?
Because there are a number of other variables that users can have (and do have) that corrupt the build, for example:
C_INCLUDE_PATHCPLUS_INCLUDE_PATHLIBRARY_PATHLD_LIBRARY_PATH
PERL5LIBGCC_EXEC_PREFIXIn the twisted environments that I'm working in, I'm unsetting these from a wrapper around buildroot make. However, it seems that there already are a number of cleanups done inside buildroot itself, so it makes sense to add the above variables to the list.
Quoted 5 lines
Quoted 1 line
What do you think?
How about going all the way: clean out the environment completely, and explicitly add env vars to builders as needed. That would result in a more deterministic build environment, IMHO.
It's true that it would be deterministic, but I'm not sure if it's always correct. There are some environment variables that could be needed for a correct build, like proxy settings. Clearing them out will be a problem in such cases.
So either we should work with a whitelist of safe flags, or keep the existing environment but delete items on the blacklist.
PATCH 1/1 Makefile: unset MAKEFLAGS
In reply to Bjørn ForsmanDear Bj?rn Forsman,
Quoted 3 lines · Bj?rn Forsman
How about going all the way: clean out the environment completely, and explicitly add env vars to builders as needed. That would result in a more deterministic build environment, IMHO.
I don't think this works: there are a bunch of environment variables that we accept (to tune the uClibc config file, the Busybox config file, the host gcc to use, etc.). And we also accept the feature that all BR2_<foo> values can be overridden using environment variables. So I don't think wiping out the entire environment is possible. However, we could /maybe/ (if that's possible), wipe out the entire environment *except* the BR2_<foo> variables, and the few other variables that we explicitly accept. But I'm not sure how to achieve that.
Best regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 Makefile: unset MAKEFLAGS
Thomas, All,
Quoted 5 lines · On Thursday 11 July 2013 13:46:46 Thomas Petazzoni wrote:
Quoted 3 lines · Bj?rn Forsman
How about going all the way: clean out the environment completely, and explicitly add env vars to builders as needed. That would result in a more deterministic build environment, IMHO.
Quoted 8 lines
I don't think this works: there are a bunch of environment variables that we accept (to tune the uClibc config file, the Busybox config file, the host gcc to use, etc.). And we also accept the feature that all BR2_<foo> values can be overridden using environment variables. So I don't think wiping out the entire environment is possible. However, we could /maybe/ (if that's possible), wipe out the entire environment *except* the BR2_<foo> variables, and the few other variables that we explicitly accept. But I'm not sure how to achieve that.
Even that would not work. For example, I have LD_PRELOAD set to tsocksify all network connections, without which I could not download anything.
So, even though LD_PRELOAD looks like a good candidate to dump, it can be valid in some cases.
I believe it is much better that Buildroot chokes on a select list of variables, warn about a few others, and accept the rest.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ | | --==< O_o >==-- '------------.-------: X AGAINST | /e\ There is no | | http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL | """ conspiracy. | '------------------------------'-------'------------------'--------------------'
PATCH 1/1 Makefile: unset MAKEFLAGS
Hi Yann,
Quoted 17 lines · Yann E. MORIN
Thomas, All,
Quoted 5 lines · On Thursday 11 July 2013 13:46:46 Thomas Petazzoni wrote:
Quoted 3 lines · Bj?rn Forsman
How about going all the way: clean out the environment completely, and explicitly add env vars to builders as needed. That would result in a more deterministic build environment, IMHO.
Quoted 8 lines
I don't think this works: there are a bunch of environment variables that we accept (to tune the uClibc config file, the Busybox config file, the host gcc to use, etc.). And we also accept the feature that all BR2_<foo> values can be overridden using environment variables. So I don't think wiping out the entire environment is possible. However, we could /maybe/ (if that's possible), wipe out the entire environment *except* the BR2_<foo> variables, and the few other variables that we explicitly accept. But I'm not sure how to achieve that.
Quoted 8 lines
Even that would not work. For example, I have
LD_PRELOADset to tsocksify all network connections, without which I could not download anything.So, even though
LD_PRELOADlooks like a good candidate to dump, it can be valid in some cases.I believe it is much better that Buildroot chokes on a select list of variables, warn about a few others, and accept the rest.
But with this policy, all existing 'unexports' in the Makefile should be removed, and it's up to the user to fix his stuff.
In corporate environments, for one, this is not always feasible. Many developers will build with buildroot as part of an overall build process, and will not know anything about buildroot itself nor its requirements. So either the overall build process should clear the user's environment before starting the buildroot build, or buildroot itself should clean up what it knows is problematic.
Since there already are several variables cleared in that way, I'm more in favor in going down that path and adding some more troublesome variables, rather than removing these bits altogether.
PATCH 1/1 Makefile: unset MAKEFLAGS
Quoted 9 lines · Thomas De Schampheleire
But with this policy, all existing 'unexports' in the
Makefileshould be removed, and it's up to the user to fix his stuff.
In corporate environments, for one, this is not always feasible. Many developers will build with buildroot as part of an overall build process, and will not know anything about buildroot itself nor its requirements. So either the overall build process should clear the user's environment before starting the buildroot build, or buildroot itself should clean up what it knows is problematic.
Quoted 3 lines
Since there already are several variables cleared in that way, I'm more in favor in going down that path and adding some more troublesome variables, rather than removing these bits altogether.
I agree.
At the moment it's working quite well as it is, maybe we should add some extra unexports in the main Makefile for things that are known to be troublesome.
For instance on Gentoo RUBYOPT is set, and when buildroot builds host-ruby this causes problems.
The best solution would be to unexport RUBYOPT (and RUBYLIB while at it), i just didn't send a patch yet because i'm looking at the thread to see how it pans out :)
Regards.
PATCH 1/1 Makefile: unset MAKEFLAGS
In reply to Yann E. MORINQuoted 17 lines · Yann E. MORIN
Thomas, All,
Quoted 5 lines · On Thursday 11 July 2013 13:46:46 Thomas Petazzoni wrote:
Quoted 3 lines · Bj?rn Forsman
How about going all the way: clean out the environment completely, and explicitly add env vars to builders as needed. That would result in a more deterministic build environment, IMHO.
Quoted 8 lines
I don't think this works: there are a bunch of environment variables that we accept (to tune the uClibc config file, the Busybox config file, the host gcc to use, etc.). And we also accept the feature that all BR2_<foo> values can be overridden using environment variables. So I don't think wiping out the entire environment is possible. However, we could /maybe/ (if that's possible), wipe out the entire environment *except* the BR2_<foo> variables, and the few other variables that we explicitly accept. But I'm not sure how to achieve that.
Quoted 8 lines
Even that would not work. For example, I have
LD_PRELOADset to tsocksify all network connections, without which I could not download anything.So, even though
LD_PRELOADlooks like a good candidate to dump, it can be valid in some cases.I believe it is much better that Buildroot chokes on a select list of variables, warn about a few others, and accept the rest.
If you think about it, the downloader is actually a bit different from the builder. At some point Buildroot will (like all other build systems) grow support for checking each downloaded file against checksums specified in the package build file. And once you have that, it doesn't really matter how dirty the environment in the *downloader* is, because it will be guaranteed to match the checksum, or fail. It is only in the *builder* that the environment must be clean.
Are there any reasons for allowing env vars, other than BR2_*, to slip through from host and into the Buildroot *builder* processes? I cannot think of any.
Best regards,
Bj?rn Forsman
PATCH 1/1 Makefile: unset MAKEFLAGS
Dear Bj?rn Forsman,
Quoted 10 lines · Bj?rn Forsman
Quoted 2 lines
I believe it is much better that Buildroot chokes on a select list of variables, warn about a few others, and accept the rest.
If you think about it, the downloader is actually a bit different from the builder. At some point Buildroot will (like all other build systems) grow support for checking each downloaded file against checksums specified in the package build file. And once you have that, it doesn't really matter how dirty the environment in the *downloader* is, because it will be guaranteed to match the checksum, or fail. It is only in the *builder* that the environment must be clean.
I am not sure to understand why you separate the download side and the build side here. Both are done with Buildroot makefiles, there is nothing different in terms of environment variables between those steps.
Quoted 3 lines
Are there any reasons for allowing env vars, other than BR2_*, to slip through from host and into the Buildroot *builder* processes? I cannot think of any.
Yes, we allow passing HOSTCC, UCLIBC_CONFIG_FILE, BUSYBOX_CONFIG_FILE, and a bunch of other environment variables (see the Buildroot manual). Also, some environment variables like LD_LIBRARY_PATH or LD_PRELOAD should just be usable by the user, if he has some funky setup that requires those environment variables to hold special values.
Best regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 Makefile: unset MAKEFLAGS
Quoted 15 lines · Thomas Petazzoni
Dear Bj?rn Forsman,
Quoted 10 lines · Bj?rn Forsman
Quoted 2 lines
I believe it is much better that Buildroot chokes on a select list of variables, warn about a few others, and accept the rest.
If you think about it, the downloader is actually a bit different from the builder. At some point Buildroot will (like all other build systems) grow support for checking each downloaded file against checksums specified in the package build file. And once you have that, it doesn't really matter how dirty the environment in the *downloader* is, because it will be guaranteed to match the checksum, or fail. It is only in the *builder* that the environment must be clean.
Quoted 4 lines
I am not sure to understand why you separate the download side and the build side here. Both are done with Buildroot makefiles, there is nothing different in terms of environment variables between those steps.
They are not separate right now, but they could be. Because of the possibility to use checksums to verify the downloader, and because that is not possible to do with the builder, I think the two can be seen as quite different things.
Even though they are both implemented in makefiles, I don't think it's difficult to run them in different environments. man env ?
Quoted 6 lines
Quoted 3 lines
Are there any reasons for allowing env vars, other than BR2_*, to slip through from host and into the Buildroot *builder* processes? I cannot think of any.
Yes, we allow passing HOSTCC,
UCLIBC_CONFIG_FILE,BUSYBOX_CONFIG_FILE, and a bunch of other environment variables (see the Buildroot manual).
Ok. Those variables are special to Buildroot, similar to BR2_* vars. So I think they fall under the same category. In fact, they *could* be renamed to BR2_*, because the are non-standard anyways, unlike LD_LIBRARY_PATH etc. Note that I'm not suggesting that they are renamed, just that they are Buildroot specific.
Quoted 3 lines
Also, some environment variables like
LD_LIBRARY_PATHorLD_PRELOADshould just be usable by the user, if he has some funky setup that requires those environment variables to hold special values.
Are you thinking of Yann's use case? That was for the download phase, which I agree could run in an unmodified host environment. I was asking if it would make any sense to allow LD_LIBRARY_PATH etc. into the *build* phase (configure && make). I think the build phase is the one where most bugs happen because of different host environments :-)
Anyways, I was just throwing my idea out there. I've been playing with nixos[1] lately, and have been inspired by its "pure" build system. It tries very hard to prevent the host environment from affecting the build result.
Best regards,
Bj?rn Forsman
PATCH 1/1 Makefile: unset MAKEFLAGS
In reply to Thomas De SchampheleireDear Thomas De Schampheleire,
Quoted 12 lines · Thomas De Schampheleire
What is the strategy with respect to cleaning up the user's environment when building buildroot?
Because there are a number of other variables that users can have (and do have) that corrupt the build, for example:
C_INCLUDE_PATHCPLUS_INCLUDE_PATHLIBRARY_PATHLD_LIBRARY_PATH
PERL5LIBGCC_EXEC_PREFIX
Quoted 6 lines
In the twisted environments that I'm working in, I'm unsetting these from a wrapper around buildroot make. However, it seems that there already are a number of cleanups done inside buildroot itself, so it makes sense to add the above variables to the list.
What do you think?
We have are a bit inconsistent on this. Some variables are unset from the main Makefile, and a bunch of others are checked in support/dependencies/dependencies.sh. For example, LD_LIBRARY_PATH which you mentioned get checked in support/dependencies/dependencies.sh.
Looks like a bit of cleanup in this area might be useful.
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 Makefile: unset MAKEFLAGS
Hi Thomas,
Quoted 21 lines · Thomas Petazzoni
Dear Thomas De Schampheleire,
Quoted 17 lines · Thomas De Schampheleire
What is the strategy with respect to cleaning up the user's environment when building buildroot?
Because there are a number of other variables that users can have (and do have) that corrupt the build, for example:
C_INCLUDE_PATHCPLUS_INCLUDE_PATHLIBRARY_PATHLD_LIBRARY_PATH
PERL5LIBGCC_EXEC_PREFIXIn the twisted environments that I'm working in, I'm unsetting these from a wrapper around buildroot make. However, it seems that there already are a number of cleanups done inside buildroot itself, so it makes sense to add the above variables to the list.
Quoted 8 lines
Quoted 1 line
What do you think?
We have are a bit inconsistent on this. Some variables are unset from the main
Makefile, and a bunch of others are checked insupport/dependencies/dependencies.sh. For example,LD_LIBRARY_PATHwhich you mentioned get checked insupport/dependencies/dependencies.sh.Looks like a bit of cleanup in this area might be useful.
dependencies.sh does not complain on the existence of LD_LIBRARY_PATH in the environment, only on the presence of the current working directory inside of it. But of course, if we decide to unexport this variable, then checking its contents is no longer needed. Is there any valid use case for someone setting LD_LIBRARY_PATH during a buildroot build?
For the check on the presence of the current working dir in PATH, we could question whether it makes sense to raise a message and exit, or to manipulate PATH during the build and continue.
Another variable checked in dependencies.sh is PERL_MM_OPT. This seems a good candidate to add to the existing list in Makefile.
Is there any particular reason why some unexports are done always, and some are done inside a check on BR2_HAVE_DOT_CONFIG ?
PATCH 1/1 Makefile: unset MAKEFLAGS
Dear Thomas De Schampheleire,
Quoted 6 lines · Thomas De Schampheleire
dependencies.shdoes not complain on the existence ofLD_LIBRARY_PATHin the environment, only on the presence of the current working directory inside of it. But of course, if we decide to unexport this variable, then checking its contents is no longer needed. Is there any valid use case for someone settingLD_LIBRARY_PATHduring a buildroot build?
I guess it could be used if someone is building manually some host tools needed by Buildroot, and a special LD_LIBRARY_PATH is needed to run such tools. But it really seems like a corner case.
Quoted 3 lines
For the check on the presence of the current working dir in PATH, we could question whether it makes sense to raise a message and exit, or to manipulate PATH during the build and continue.
True.
Quoted 2 lines
Another variable checked in
dependencies.shisPERL_MM_OPT. This seems a good candidate to add to the existing list inMakefile.
Indeed. I'm the one to blame here, I'm the one who added this variable check in dependencies.sh, if I remember correctly :)
Quoted 2 lines
Is there any particular reason why some unexports are done always, and some are done inside a check on
BR2_HAVE_DOT_CONFIG?
So, PKG_CONFIG_PATH, PKG_CONFIG_SYSROOT_DIR and DESTDIR get unset outside of the BR2_HAVE_DOT_CONFIG conditional, all the other are inside. I don't really see why we're doing that.
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com