Release build is not available for corehost
Steps to reproduce
On ubuntu.14.04-x64 host machine, run following command.
./build.sh --configuration Release
Expected behavior
corehost is built for Release with compiler optimization enabled.
Actual behavior
No compiler optimization is enabled as follows.
cd /home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/artifacts/ubuntu.14.04-x64/corehost/cmake/cli/exe/dotnet && /usr/bin/clang++-3.5 -DAPPHOST_PKG_VER=\"2.0.0-beta-001459-00\" -DHOST_FXR_PKG_VER=\"2.0.0-beta-001459-00\" -DHOST_PKG_VER=\"2.0.0-beta-001459-00\" -DHOST_POLICY_PKG_NAME=\"runtime.ubuntu.14.04-x64.Microsoft.NETCore.DotNetHostPolicy\" -DHOST_POLICY_PKG_REL_DIR=\"runtimes/ubuntu.14.04-x64/native\" -DHOST_POLICY_PKG_VER=\"2.0.0-beta-001459-00\" -DREPO_COMMIT_HASH=\"164630586895741f517c1263989447ebcb0c1d04\" -DTARGET_RUNTIME_ID=\"ubuntu.14.04-x64\" -D_NO_ASYNCRTIMP -D_NO_PPLXIMP -D_TARGET_AMD64_=1 -D__LINUX__ -std=c++11 -I/home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/src/corehost/cli/exe/dotnet/../../.. -I/home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/src/corehost/cli/exe/dotnet/../../../common -I/home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/src/corehost/cli/exe/dotnet/../.. -I/home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/src/corehost/cli/exe/dotnet/../../fxr -fPIE -Wno-unused-local-typedef -fstack-protector-strong -o CMakeFiles/dotnet.dir/__/__/__/corehost.cpp.o -c /home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/src/corehost/corehost.cpp
...
/usr/bin/clang++-3.5 -std=c++11 -Wl,--build-id=sha1 CMakeFiles/dotnet.dir/__/__/fxr/fx_ver.cpp.o CMakeFiles/dotnet.dir/__/__/__/corehost.cpp.o CMakeFiles/dotnet.dir/__/__/__/common/trace.cpp.o CMakeFiles/dotnet.dir/__/__/__/common/utils.cpp.o CMakeFiles/dotnet.dir/__/__/__/common/pal.unix.cpp.o -o dotnet -rdynamic -ldl -lpthread
...
Look into ...
For core-setup, there is --configuration option to select Debug or Release.
$ ./build.sh --help
Usage: /home/hk0110/work/dxl/dotnet/github/dotnet/core-setup/build_projects/dotnet-host-build/build.sh [--configuration <CONFIGURATION>] [--skip-prereqs] [--nopackage] [--docker <IMAGENAME>] [--help] [--targets <TARGETS...>]
Options:
--configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)
--targets <TARGETS...> Comma separated build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)
--env-vars <'V1=val1','V2=val2'...> Comma separated list of environment variables
--nopackage Skip packaging targets
--skip-prereqs Skip checks for pre-reqs in dotnet_install
--build-driver-only Just build dotnet-host-build binary
--portableLinux Optional argument to build native libraries portable over GLIBC based Linux distros.
--docker <IMAGENAME> Build in Docker using the Dockerfile located in scripts/docker/IMAGENAME
--help Display this help message
<TARGETS...> The build targets to run (Init, Compile, Publish, etc.; Default is a full build and publish)
--configuration Releaseis passed from./build.shto./build_projects/dotnet-host-build/build.shbuild_projects/dotnet-host-build/build.shdeclares environmental variableCONFIGURATIONat https://github.com/dotnet/core-setup/blob/master/build_projects/dotnet-host-build/build.sh#L67 when--configuration Releaseoption is enabled- However build script for corehost (https://github.com/dotnet/core-setup/blob/master/src/corehost/build.sh) does not consider this environmental variable (
CONFIGURATION) at all.
Is this intended behavior ?
or should we update https://github.com/dotnet/core-setup/blob/master/src/corehost/build.sh to build corehost with higher optimization level for Release ?
Same behavior is observed for arm32 cross build.
@gkhanna79 I've observed this issue while applying a workaround, i.e use -O1 for arm32 cross build as you suggested at https://github.com/dotnet/core-setup/issues/790#issuecomment-275433662.
What do you think of it ? We may not need this with current infra, because at least corehost is built without bug introduced by -O3 optimization, but we need them eventually.
Thanks for looking into this @hqueue. I am not sure if this was an oversight or not - @janvorli Do you happen to know?
That said, unless there is a seperate build configuration/options we wish to specify, we can keep this as-is for now. We can revisit it later once -O3 issue is being addressed for arm32.
@gkhanna79 I would expect consistent optimizations settings for debug / release builds over all of the binaries we build. So it seems to me that this is something we should fix eventually. I can see one use of the CONFIGURATION env variable here: build_projects/dotnet-host-build/PrepareTargets.cs But I am not familiar with this stuff so I am not sure to what it applies.
@janvorli It seems that dotnet-host-build read CONFIGURATION and use the value for packaging and testing. I think this is a correct behavior because we have to make Release and Debug packages depending on CONFIGURATION. Other than corehost, it seems that CONFIGURATION is used correctly,
I think some integration is not completed for corehost and core-setup when relocating corehost from dotnet/cli to dotnet/core-setup.