Repository navigation
Build errors under libraries/native when building with GCC #2188
Description
gcc 9.2.1
clearlinux
dotnetcore 3.1.1
./libraries.sh
First error (happens all over):
[ 2%] Building C object System.Globalization.Native/CMakeFiles/System.Globalization.Native-Static.dir/pal_calendarData.c.o
In file included from /usr/include/assert.h:35,
from /home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/AnyOS/zlib/pal_zlib.c:5:
/usr/include/features.h(382,4): error G90377845: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
Then a whole bunch of this:
cc1 : error : unrecognized command line option ‘-Wno-unknown-warning-option’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-extra-semi-stmt’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-documentation-unknown-command’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-documentation’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-reserved-id-macro’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-covered-switch-default’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-c11-extensions’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-typedef-redefinition’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-empty-translation-unit’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1 : error : unrecognized command line option ‘-Wno-disabled-macro-expansion’ [-Werror] [/home/pc/workarea/test/dotnet-runtime-src/src/libraries/Native/build-native.proj]
cc1: all warnings being treated as errors
Activity
[-]Build errors[/-][+]Build errors under libraries/native when building with GCC[/+]am11 commentedon Jan 26, 2020
In the stock Clear Linux docker, these environment variables are set:
we just need to make sure to not pass that
CFlagsto build script, so instead of:CLR_CC=$(command -v gcc) ./libraries.shdo:
and the build will succeed.
we can unset fortification and other flags explicitly which cause build failure if inherited by the environment to avoid such issues.
cc @janvorli
Edit - this issue is not specific to gcc, clang on Clear Linux also fail to compile unless we clear
CFLAGSdefined in environment.Meai commentedon Feb 6, 2020
@am11 I tried that and now I still get errors but different ones:
(I git pulled first, now on commit 04e3169)
am11 commentedon Feb 6, 2020
There are two parts: managed and native. The native build uses gcc/clang. In the current master we can also pass
--clangor--gccfrom top level scripts:runtime/build.sh --gccorruntimte/libraries.sh --clang9etc.this sounds like a separate issue with managed build failing, because some conflicting assemblies trying to load in the same appdomain. Could you
ps uax | grep dotnetandkill -KILL <space-separated list of pids>all the pids you find in ps output, thengit clean -xdfbefore reattempting to build?command for complete product release build + packages using gcc will look like this:
cd dotnet-runtime ./build.sh --configuration release --gcc ./build.sh --configuration release --subset PkgProjthe packages will end up at
./artifacts/packages/Release/Shipping/.Meai commentedon Feb 6, 2020
Ok I did that and then:
still some errors:
jkotas commentedon Mar 16, 2020
#33446 added CI testing for GCC build. The master should be always buildable with GCC now.
am11 commentedon Mar 17, 2020
For completeness, this issue is actually about build failure on official Clear Linux image, where
CFLAGSandCXXLAGSare already set in the environment. Build fails with Clang the same way it fails with GCC. I think we should fix it by setting the values of these flags explicitly and conciously; more importantly this tells us that CoreCLR is not_FORTIFY_SOURCEcompatible: https://access.redhat.com/blogs/766093/posts/1976213, so it would be good to set flags value in base cmake script.Here is a docker file @Meai, which completely builds the current master (I tested d6bf13a) on Clear Linux (relevant line is
ENV CFLAGS...)jkotas commentedon Mar 17, 2020
@am11 Do you plan to submit a PR for this?
am11 commentedon Mar 17, 2020
Sure, I will try to make build work on Clear Linux without needing to unset
C{XX}FLAGS.