Linuxbrew / brew

:beer::penguin: The Homebrew package manager for Linux
https://linuxbrew.sh
BSD 2-Clause "Simplified" License
2.66k stars 237 forks source link

ENV.cppflags doesn't contains flags from CPPFLAGS env variable #865

Closed ttyusupov closed 6 years ago

ttyusupov commented 6 years ago

Trying to install openssl with specific compiler flags:

export CPPFLAGS="-mno-avx -mno-bmi -mno-bmi2 -mno-fma -no-abm -no-movbe"

But these flags are not applied:

16:50 $ ./bin/brew reinstall openssl
==> Reinstalling openssl
==> Downloading https://www.openssl.org/source/openssl-1.0.2p.tar.gz
Already downloaded: /home/centos/.cache/Homebrew/downloads/6d2f0aa30538560efe2aae756229a9ced40e636a70083696fb1bceb6c1a7564c--openssl-1.0.2p.tar.gz
==> perl ./Configure --prefix=/home/centos/code/brew/Cellar/openssl/1.0.2p --openssldir=/home/centos/code/brew/etc/openssl no-ssl2 no-ssl3 no-zlib shared enable-cms -Wa,--noexecstack linux-x86_64

ENV.cppflags are considered by https://github.com/Linuxbrew/homebrew-core/blob/master/Formula/openssl.rb#L58, but ENV.cppflags does not include value of CPPFLAGS env variable.

May be I should use another approach to pass flags into ENV.cppflags?

sjackman commented 6 years ago

Homebrew and Linuxbrew by design do not use the users's environment variables to ensure a reproducible build. You may if you like brew edit openssl to edit the formula and add these options to CFLAGS using ENV.append_to_cflags "-mno-avx -mno-bmi -mno-bmi2 -mno-fma -no-abm -no-movbe".

ttyusupov commented 6 years ago

Is there any other way to update common ENV contents externally without editing formulas for specific packages and patching Linuxbrew source code?

sjackman commented 6 years ago

No, there is not.

sjackman commented 6 years ago

There is for environment variables not on this black list: https://github.com/Linuxbrew/brew/blob/9bb758143534754facc589b6d6f8335f1794695d/Library/Homebrew/extend/ENV/shared.rb#L18-L27