-
Notifications
You must be signed in to change notification settings - Fork 66
[ML] Use hardened compiler options to build 3rd party libraries #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change adds the stack protector, relro and fortify source options to the commands used to build the 3rd party libraries we use on Linux. (We already used these options when building our own code.)
ENV PATH /usr/local/gcc73/bin:/usr/bin:/bin:/usr/sbin:/sbin | ||
|
||
# For compiling in C++14 mode | ||
# For compiling in C++14 mode with hardening and optimisation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that optimisation was not added in this commit. If CFLAGS
is not specified then the configure
scripts use a default value for it, and this invariably includes optimisation. It's only because we are now specifying CFLAGS
that we have to explicitly add the optimisation option now.
``` | ||
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | ||
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | ||
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have a second define
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s fine to have two (or more) define
s here. They become multiple -D
arguments on the compiler command line, which is a very usual thing to have.
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | ||
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | ||
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now | ||
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
echo " Building..." | ||
./b2 -j$NUMCPUS --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS > b2_make.log 2>&1 | ||
./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS > b2_make_install.log 2>&1 | ||
./b2 -j$NUMCPUS --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now > b2_make.log 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second define
in this and the following line is well (if it is an issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This change adds the stack protector, relro and fortify source options to the commands used to build the 3rd party libraries we use on Linux. (We already used these options when building our own code.) Backport of elastic#453
This change adds the stack protector, relro and fortify source options to the commands used to build the 3rd party libraries we use on Linux. (We already used these options when building our own code.) Backport of #453
This is a follow on to elastic#453 The stack protector, relro and fortify source options need to be used when building gcc, because we redistribute two libraries that are built as part of it, namely libgcc_s.so.1 and libstdc++.so.6.
This is a follow on to #453 The stack protector, relro and fortify source options need to be used when building gcc, because we redistribute two libraries that are built as part of it, namely libgcc_s.so.1 and libstdc++.so.6.
This is a follow on to elastic#453 The stack protector, relro and fortify source options need to be used when building gcc, because we redistribute two libraries that are built as part of it, namely libgcc_s.so.1 and libstdc++.so.6. Backport of elastic#470
This change adds the stack protector, relro and fortify source
options to the commands used to build the 3rd party libraries
we use on Linux.
(We already used these options when building our own code.)