dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.39k stars 4.75k forks source link

Cannot build for x86 #8681

Closed kentcb closed 4 years ago

kentcb commented 7 years ago

I've been trying to follow dotnet/runtime#7335 wherein @parjong provides some instructions on building for x86. I'm using an Ubuntu 16.04 docker image as a base. Once all my dependencies were installed, the build failed as follows:

root@1a2e9e291e3f:/home/coreclr# ./build.sh cross x86  skipnuget debug cmakeargs "-DSKIP_LLDBPLUGIN=true" clang3.8
Commencing CoreCLR Repo build
WARNING: Can not determine runtime id for current distro.
Setting up directories for build
Checking prerequisites...
Installing dotnet cli...
Restoring BuildTools version 2.0.0-prerelease-01812-02...
Failed to load /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so'
ERROR: Could not restore build tools correctly.
Please check the detailed log that follows.
Running: /home/coreclr/init-tools.sh
Installing 'https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.0-preview1-005724/dotnet-dev-linux-x64.2.0.0-preview1-005724.tar.gz' to '/home/coreclr/Tools/dotnetcli/dotnet.tar'
Running: /home/coreclr/Tools/dotnetcli/dotnet restore "/home/coreclr/init-tools.msbuild" --no-cache --packages /home/coreclr/packages --source https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json /p:BuildToolsPackageVersion=2.0.0-prerelease-01812-02
Initializing BuildTools...
chmod: cannot access '/home/coreclr/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01812-02/lib/init-tools.sh': No such file or directory
/home/coreclr/init-tools.sh: line 114: /home/coreclr/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01812-02/lib/init-tools.sh: No such file or directory
ERROR: An error occurred when trying to initialize the tools.
Please check the detailed log that follows.
Running: /home/coreclr/init-tools.sh
Installing 'https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.0-preview1-005724/dotnet-dev-linux-x64.2.0.0-preview1-005724.tar.gz' to '/home/coreclr/Tools/dotnetcli/dotnet.tar'
Running: /home/coreclr/Tools/dotnetcli/dotnet restore "/home/coreclr/init-tools.msbuild" --no-cache --packages /home/coreclr/packages --source https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json /p:BuildToolsPackageVersion=2.0.0-prerelease-01812-02
Running: /home/coreclr/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01812-02/lib/init-tools.sh /home/coreclr /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools
Failed to restore buildtools.

I checked, and indeed the /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libunwind.so file does not exist (though the libcoreclr.so file does).

When I tried building again, it failed again, but with different output:

root@1a2e9e291e3f:/home/coreclr# ./build.sh cross x86  skipnuget debug cmakeargs "-DSKIP_LLDBPLUGIN=true" clang3.8
Commencing CoreCLR Repo build
WARNING: Can not determine runtime id for current distro.
Setting up directories for build
Checking prerequisites...
Failed to load /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so'
Failed to load /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so'
Laying out dynamically generated files consumed by the build system
Laying out dynamically generated Event Logging Test files
Generating Event Logging Tests
Laying out dynamically generated EventPipe Implementation
Laying out dynamically generated Event Logging Implementation of Lttng
Cleaning the temp folder of dynamically generated Event Logging files
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider with /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider_new
Cleaning the temp folder of dynamically generated EventPipe files
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe with /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe_new
Commencing build of CoreCLR component for Linux.x86.Debug in /home/coreclr/bin/obj/Linux.x86.Debug
/home/coreclr
Running init-tools.sh
Installing dotnet cli...
Restoring BuildTools version 2.0.0-prerelease-01812-02...
Failed to load /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so'
ERROR: Could not restore build tools correctly.
Please check the detailed log that follows.
Running: /home/coreclr/init-tools.sh
Installing 'https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.0-preview1-005724/dotnet-dev-linux-x64.2.0.0-preview1-005724.tar.gz' to '/home/coreclr/Tools/dotnetcli/dotnet.tar'
Running: /home/coreclr/Tools/dotnetcli/dotnet restore "/home/coreclr/init-tools.msbuild" --no-cache --packages /home/coreclr/packages --source https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json /p:BuildToolsPackageVersion=2.0.0-prerelease-01812-02
Initializing BuildTools...
chmod: cannot access '/home/coreclr/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01812-02/lib/init-tools.sh': No such file or directory
/home/coreclr/init-tools.sh: line 114: /home/coreclr/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01812-02/lib/init-tools.sh: No such file or directory
ERROR: An error occurred when trying to initialize the tools.
Please check the detailed log that follows.
Running: /home/coreclr/init-tools.sh
Installing 'https://dotnetcli.azureedge.net/dotnet/Sdk/2.0.0-preview1-005724/dotnet-dev-linux-x64.2.0.0-preview1-005724.tar.gz' to '/home/coreclr/Tools/dotnetcli/dotnet.tar'
Running: /home/coreclr/Tools/dotnetcli/dotnet restore "/home/coreclr/init-tools.msbuild" --no-cache --packages /home/coreclr/packages --source https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json /p:BuildToolsPackageVersion=2.0.0-prerelease-01812-02
Running: /home/coreclr/packages/microsoft.dotnet.buildtools/2.0.0-prerelease-01812-02/lib/init-tools.sh /home/coreclr /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools
Running: /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools/run.exe /home/coreclr/config.json build -Project=/home/coreclr/build.proj -generateHeaderUnix -NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp -BuildArch=x86 -BuildType=Debug -BuildOS=Linux
Failed to load /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so'
ERROR: An error occured in /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools/run 7. Check 7 logs under /home/coreclr.
/home/coreclr/bin/obj/Linux.x86.Debug /home/coreclr
Invoking "/home/coreclr/src/pal/tools/gen-buildsys-clang.sh" "/home/coreclr" 3 8 x86 Debug  Include_Tests  -DCLR_CMAKE_TARGET_OS=Linux -DCLR_CMAKE_PACKAGES_DIR=/home/coreclr/packages -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_VERSION= -DCLR_CMAKE_PGO_OPTIMIZE=1  -DSKIP_LLDBPLUGIN=true
Including tests directory in build.
loading initial cache file /home/coreclr/cross/x86/tryrun.cmake
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /usr/bin/clang-3.8
-- Check for working C compiler: /usr/bin/clang-3.8 -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/clang-3.8" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/make" "cmTC_ca561/fast"

  /usr/bin/make -f CMakeFiles/cmTC_ca561.dir/build.make
  CMakeFiles/cmTC_ca561.dir/build

  make[1]: Entering directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_ca561.dir/testCCompiler.c.o

  /usr/bin/clang-3.8 -Wall -std=c11 -m32
  --sysroot=/home/coreclr/cross/rootfs/x86
  -Wno-error=unused-command-line-argument -o
  CMakeFiles/cmTC_ca561.dir/testCCompiler.c.o -c
  /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTC_ca561

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ca561.dir/link.txt
  --verbose=1

  /usr/bin/clang-3.8 -Wall -std=c11 --sysroot=/home/coreclr/cross/rootfs/x86
  -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu
  -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32
  CMakeFiles/cmTC_ca561.dir/testCCompiler.c.o -o cmTC_ca561 -rdynamic

  /usr/bin/ld: cannot find crt1.o: No such file or directory

  /usr/bin/ld: cannot find crti.o: No such file or directory

  /usr/bin/ld: cannot find crtbegin.o: No such file or directory

  /usr/bin/ld: cannot find -lgcc

  /usr/bin/ld: cannot find -lgcc_s

  /usr/bin/ld: cannot find -lc

  /usr/bin/ld: cannot find -lgcc

  /usr/bin/ld: cannot find -lgcc_s

  /usr/bin/ld: cannot find crtend.o: No such file or directory

  /usr/bin/ld: cannot find crtn.o: No such file or directory

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  CMakeFiles/cmTC_ca561.dir/build.make:97: recipe for target 'cmTC_ca561'
  failed

  make[1]: *** [cmTC_ca561] Error 1

  make[1]: Leaving directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Makefile:126: recipe for target 'cmTC_ca561/fast' failed

  make: *** [cmTC_ca561/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:9 (project)

-- Configuring incomplete, errors occurred!
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeOutput.log".
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeError.log".
/home/coreclr
Failed to generate CoreCLR component build project!

Can someone please help me diagnose and move forward with this? Ultimately I wish to run x86 .NET Core on a 32-bit Gentoo system.

parjong commented 7 years ago

Failed to load /home/coreclr/Tools/dotnetcli/shared/Microsoft.NETCore.App/2.0.0-preview1-001913-00/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory

You first need to install libunwind8 (or libunwind8-dev) that dotnet SDK for x64/Linux requires.

kentcb commented 7 years ago

Thanks @parjong - that certainly gets me further (I wonder if the build script should warn when libunwind isn't installed...)

Now I get this output:

<snip>
Crossgen finished.
Done initializing tools.
Running: /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools/run.exe /home/coreclr/config.json build -Project=/home/coreclr/build.proj -generateHeaderUnix -NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp -BuildArch=x86 -BuildType=Debug -BuildOS=Linux
Running: /home/coreclr/Tools/msbuild.sh /nologo /verbosity:minimal /clp:Summary /maxcpucount  /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log  /home/coreclr/build.proj /p:__BuildType=Debug /p:__BuildArch=x86 /p:__BuildOS=Linux  /t:GenerateVersionSourceFile /p:GenerateVersionSourceFile=true /p:NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp /p:RestoreDefaultOptimizationDataPackage=false /p:UsePartialNGENOptimization=false /p:PortableBuild=true

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.40
Command execution succeeded.
Command successfully completed.
/home/coreclr/bin/obj/Linux.x86.Debug /home/coreclr
Invoking "/home/coreclr/src/pal/tools/gen-buildsys-clang.sh" "/home/coreclr" 3 8 x86 Debug  Include_Tests  -DCLR_CMAKE_TARGET_OS=Linux -DCLR_CMAKE_PACKAGES_DIR=/home/coreclr/packages -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_VERSION=99.99.99-master-20170712-0121 -DCLR_CMAKE_PGO_OPTIMIZE=1  -DSKIP_LLDBPLUGIN=true
Including tests directory in build.
loading initial cache file /home/coreclr/cross/x86/tryrun.cmake
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /usr/bin/clang-3.8
-- Check for working C compiler: /usr/bin/clang-3.8 -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/clang-3.8" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/make" "cmTC_ddd0d/fast"

  /usr/bin/make -f CMakeFiles/cmTC_ddd0d.dir/build.make
  CMakeFiles/cmTC_ddd0d.dir/build

  make[1]: Entering directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_ddd0d.dir/testCCompiler.c.o

  /usr/bin/clang-3.8 -Wall -std=c11 -m32
  --sysroot=/home/coreclr/cross/rootfs/x86
  -Wno-error=unused-command-line-argument -o
  CMakeFiles/cmTC_ddd0d.dir/testCCompiler.c.o -c
  /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTC_ddd0d

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ddd0d.dir/link.txt
  --verbose=1

  /usr/bin/clang-3.8 -Wall -std=c11 --sysroot=/home/coreclr/cross/rootfs/x86
  -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu
  -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32
  CMakeFiles/cmTC_ddd0d.dir/testCCompiler.c.o -o cmTC_ddd0d -rdynamic

  /usr/bin/ld: cannot find crt1.o: No such file or directory

  /usr/bin/ld: cannot find crti.o: No such file or directory

  /usr/bin/ld: cannot find crtbegin.o: No such file or directory

  /usr/bin/ld: cannot find -lgcc

  /usr/bin/ld: cannot find -lgcc_s

  /usr/bin/ld: cannot find -lc

  /usr/bin/ld: cannot find -lgcc

  /usr/bin/ld: cannot find -lgcc_s

  /usr/bin/ld: cannot find crtend.o: No such file or directory

  /usr/bin/ld: cannot find crtn.o: No such file or directory

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  CMakeFiles/cmTC_ddd0d.dir/build.make:97: recipe for target 'cmTC_ddd0d'
  failed

  make[1]: *** [cmTC_ddd0d] Error 1

  make[1]: Leaving directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Makefile:126: recipe for target 'cmTC_ddd0d/fast' failed

  make: *** [cmTC_ddd0d/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:9 (project)

-- Configuring incomplete, errors occurred!
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeOutput.log".
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeError.log".
/home/coreclr
Failed to generate CoreCLR component build project!

The contents of CMakeOutput.log doesn't appear to contain anything of interest:

The target system is: Linux -  - i686
The host system is: Linux - 4.9.36-moby - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/clang-3.8
Build flags:
Id flags:

The output was:
0

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is Clang, found in "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/3.5.1/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /usr/bin/clang++-3.8
Build flags:
Id flags:

The output was:
0

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is Clang, found in "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/3.5.1/CompilerIdCXX/a.out"

Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/clang-3.8
Build flags: ;-Wall;-std=c11
Id flags:

The output was:
0

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is Clang, found in "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/3.5.1/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /usr/bin/clang++-3.8
Build flags:
Id flags:

The output was:
0

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is Clang, found in "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/3.5.1/CompilerIdCXX/a.out"

Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/clang-3.8
Build flags: ;-Wall;-std=c11
Id flags:

The output was:
0

But CMakeError.log seems to provide some indications:

Determining if the C compiler works failed with the following output:
Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_cb7bd/fast"
/usr/bin/make -f CMakeFiles/cmTC_cb7bd.dir/build.make CMakeFiles/cmTC_cb7bd.dir/build
make[1]: Entering directory '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_cb7bd.dir/testCCompiler.c.o
/usr/bin/clang-3.8    -Wall -std=c11    -m32 --sysroot=/home/coreclr/cross/rootfs/x86 -Wno-error=unused-command-line-argument -o CMakeFiles/cmTC_cb7bd.dir/testCCompiler.c.o   -c /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_cb7bd
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cb7bd.dir/link.txt --verbose=1
/usr/bin/clang-3.8   -Wall -std=c11        --sysroot=/home/coreclr/cross/rootfs/x86 -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32  CMakeFiles/cmTC_cb7bd.dir/testCCompiler.c.o  -o cmTC_cb7bd -rdynamic
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtend.o: No such file or directory
/usr/bin/ld: cannot find crtn.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_cb7bd.dir/build.make:97: recipe for target 'cmTC_cb7bd' failed
make[1]: *** [cmTC_cb7bd] Error 1
make[1]: Leaving directory '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_cb7bd/fast' failed
make: *** [cmTC_cb7bd/fast] Error 2

Determining if the C compiler works failed with the following output:
Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_ca561/fast"
/usr/bin/make -f CMakeFiles/cmTC_ca561.dir/build.make CMakeFiles/cmTC_ca561.dir/build
make[1]: Entering directory '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_ca561.dir/testCCompiler.c.o
/usr/bin/clang-3.8    -Wall -std=c11    -m32 --sysroot=/home/coreclr/cross/rootfs/x86 -Wno-error=unused-command-line-argument -o CMakeFiles/cmTC_ca561.dir/testCCompiler.c.o   -c /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_ca561
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ca561.dir/link.txt --verbose=1
/usr/bin/clang-3.8   -Wall -std=c11        --sysroot=/home/coreclr/cross/rootfs/x86 -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32  CMakeFiles/cmTC_ca561.dir/testCCompiler.c.o  -o cmTC_ca561 -rdynamic
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtend.o: No such file or directory
/usr/bin/ld: cannot find crtn.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_ca561.dir/build.make:97: recipe for target 'cmTC_ca561' failed
make[1]: *** [cmTC_ca561] Error 1
make[1]: Leaving directory '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_ca561/fast' failed
make: *** [cmTC_ca561/fast] Error 2
parjong commented 7 years ago

Did you create a cross rootfs? You may create it using the following command:

coreclr/cross$ sudo ./build-rootfs.sh x86

As I remember, you need debootstrap and qemu-user-static in order to run this script.

kentcb commented 7 years ago

No I had not (didn't realise that was a required step). I've just done that and it completed with these warnings:

W: Failure trying to run: chroot /home/coreclr/cross/rootfs/x86 mount -t proc proc /proc
W: See /home/coreclr/cross/rootfs/x86/debootstrap/debootstrap.log for details

Now when I try and build, it seems to fail in the same way:

root@1a2e9e291e3f:/home/coreclr# ./build.sh cross x86  skipnuget debug cmakeargs "-DSKIP_LLDBPLUGIN=true" clang3.8
Commencing CoreCLR Repo build
Setting up directories for build
Checking prerequisites...
Laying out dynamically generated files consumed by the build system
Laying out dynamically generated Event Logging Test files
Generating Event Logging Tests
Laying out dynamically generated EventPipe Implementation
Laying out dynamically generated Event Logging Implementation of Lttng
Cleaning the temp folder of dynamically generated Event Logging files
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider with /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider_new
Cleaning the temp folder of dynamically generated EventPipe files
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe with /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe_new
Commencing build of CoreCLR component for Linux.x86.Debug in /home/coreclr/bin/obj/Linux.x86.Debug
/home/coreclr
Running init-tools.sh
Tools are already initialized
Running: /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools/run.exe /home/coreclr/config.json build -Project=/home/coreclr/build.proj -generateHeaderUnix -NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp -BuildArch=x86 -BuildType=Debug -BuildOS=Linux
Running: /home/coreclr/Tools/msbuild.sh /nologo /verbosity:minimal /clp:Summary /maxcpucount  /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log  /home/coreclr/build.proj /p:__BuildType=Debug /p:__BuildArch=x86 /p:__BuildOS=Linux  /t:GenerateVersionSourceFile /p:GenerateVersionSourceFile=true /p:NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp /p:RestoreDefaultOptimizationDataPackage=false /p:UsePartialNGENOptimization=false /p:PortableBuild=true

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.88
Command execution succeeded.
Command successfully completed.
/home/coreclr/bin/obj/Linux.x86.Debug /home/coreclr
Invoking "/home/coreclr/src/pal/tools/gen-buildsys-clang.sh" "/home/coreclr" 3 8 x86 Debug  Include_Tests  -DCLR_CMAKE_TARGET_OS=Linux -DCLR_CMAKE_PACKAGES_DIR=/home/coreclr/packages -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_VERSION=99.99.99-master-20170712-0121 -DCLR_CMAKE_PGO_OPTIMIZE=1  -DSKIP_LLDBPLUGIN=true
Including tests directory in build.
loading initial cache file /home/coreclr/cross/x86/tryrun.cmake
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /usr/bin/clang-3.8
-- Check for working C compiler: /usr/bin/clang-3.8 -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/clang-3.8" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/make" "cmTC_f06e1/fast"

  /usr/bin/make -f CMakeFiles/cmTC_f06e1.dir/build.make
  CMakeFiles/cmTC_f06e1.dir/build

  make[1]: Entering directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_f06e1.dir/testCCompiler.c.o

  /usr/bin/clang-3.8 -Wall -std=c11 -m32
  --sysroot=/home/coreclr/cross/rootfs/x86
  -Wno-error=unused-command-line-argument -o
  CMakeFiles/cmTC_f06e1.dir/testCCompiler.c.o -c
  /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTC_f06e1

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f06e1.dir/link.txt
  --verbose=1

  /usr/bin/clang-3.8 -Wall -std=c11 --sysroot=/home/coreclr/cross/rootfs/x86
  -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu
  -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32
  CMakeFiles/cmTC_f06e1.dir/testCCompiler.c.o -o cmTC_f06e1 -rdynamic

  /usr/bin/ld: cannot find crt1.o: No such file or directory

  /usr/bin/ld: cannot find crti.o: No such file or directory

  /usr/bin/ld: cannot find -lc

  /usr/bin/ld: cannot find crtn.o: No such file or directory

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  CMakeFiles/cmTC_f06e1.dir/build.make:97: recipe for target 'cmTC_f06e1'
  failed

  make[1]: *** [cmTC_f06e1] Error 1

  make[1]: Leaving directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Makefile:126: recipe for target 'cmTC_f06e1/fast' failed

  make: *** [cmTC_f06e1/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:9 (project)

-- Configuring incomplete, errors occurred!
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeOutput.log".
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeError.log".
/home/coreclr
Failed to generate CoreCLR component build project!
parjong commented 7 years ago

It seems that build-rootfs.sh failed to install required packages (as chroot failed).

What is in /home/coreclr/cross/rootfs/x86/debootstrap/debootstrap.log?

kentcb commented 7 years ago
root@1a2e9e291e3f:/home/coreclr# cat cross/rootfs/x86/debootstrap/debootstrap.log
gpgv: Signature made Thu May  8 14:20:33 2014 UTC using DSA key ID 437D05B5
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>"
gpgv: Signature made Thu May  8 14:20:33 2014 UTC using RSA key ID C0B21F32
gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>"
mount: permission denied

Not really understanding why root would be denied permission to do anything. There is no sudo on this image, which I assume is expected.

parjong commented 7 years ago

Are you running tools inside docker container? If so, you may need to specify --privileged option when you create a container. Or, you may create a rootfs in your host OS (not docker) and then use it inside container.

kentcb commented 7 years ago

Yes, this is all inside a docker container. Hmm, my host is Windows, so I'm guessing --privileged is my best option. I'm not very proficient with docker yet, so I will likely just start again tomorrow with a privileged container (I took notes, so I know what steps to take).

Thanks for the help @parjong - I'll definitely report back tomorrow!

kentcb commented 7 years ago

OK, so I started from scratch using a --privileged container and I seem to have wound up in a similar place. My build output is:


root@a2aae4b62efe:/# ./build.sh cross x86  skipnuget debug cmakeargs "-DSKIP_LLDBPLUGIN=true" clang3.8
bash: ./build.sh: No such file or directory
root@a2aae4b62efe:/# cd home/
root@a2aae4b62efe:/home# ls
Python-2.7.13  coreclr
root@a2aae4b62efe:/home# cd coreclr/
root@a2aae4b62efe:/home/coreclr# ./build.sh cross x86  skipnuget debug cmakeargs "-DSKIP_LLDBPLUGIN=true" clang3.8
Commencing CoreCLR Repo build
Setting up directories for build
Checking prerequisites...
Installing dotnet cli...
Restoring BuildTools version 2.0.0-prerelease-01812-02...
Initializing BuildTools...
Making all .sh files executable under Tools.
/home/coreclr/Tools/../Tools/crossgen/crossgen.csproj --packages /home/coreclr/Tools/../packages --source https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
  Restoring packages for /home/coreclr/Tools/crossgen/crossgen.csproj...
  Installing runtime.linux-x64.Microsoft.NETCore.DotNetAppHost 2.0.0-preview1-001913-00.
  Installing runtime.linux-x64.Microsoft.NETCore.DotNetHostResolver 2.0.0-preview1-001913-00.
  Installing runtime.linux-x64.Microsoft.NETCore.DotNetHostPolicy 2.0.0-preview1-001913-00.
  Installing runtime.linux-x64.Microsoft.NETCore.App 2.0.0-preview1-001913-00.
  Generating MSBuild file /home/coreclr/Tools/crossgen/obj/crossgen.csproj.nuget.g.props.
  Generating MSBuild file /home/coreclr/Tools/crossgen/obj/crossgen.csproj.nuget.g.targets.
  Writing lock file to disk. Path: /home/coreclr/Tools/crossgen/obj/project.assets.json
  Restore completed in 1.63 min for /home/coreclr/Tools/crossgen/crossgen.csproj.

  NuGet Config files used:
      /root/.nuget/NuGet/NuGet.Config

  Feeds used:
      https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

  Installed:
      4 package(s) to /home/coreclr/Tools/crossgen/crossgen.csproj
Running crossgen on all assemblies in /home/coreclr/Tools.
/home/coreclr/Tools/Desktop.Analyzers.dll -> /home/coreclr/Tools/Desktop.Analyzers.ni.dll
/home/coreclr/Tools/GenFacades.Core.dll -> /home/coreclr/Tools/GenFacades.Core.ni.dll
/home/coreclr/Tools/Microsoft.DotNet.PlatformAbstractions.dll -> /home/coreclr/Tools/Microsoft.DotNet.PlatformAbstractions.ni.dll
/home/coreclr/Tools/System.Composition.AttributedModel.dll -> /home/coreclr/Tools/System.Composition.AttributedModel.ni.dll
/home/coreclr/Tools/project.dll -> /home/coreclr/Tools/project.ni.dll
/home/coreclr/Tools/System.Composition.Runtime.dll -> /home/coreclr/Tools/System.Composition.Runtime.ni.dll
/home/coreclr/Tools/NuGet.LibraryModel.dll -> /home/coreclr/Tools/NuGet.LibraryModel.ni.dll
/home/coreclr/Tools/System.Security.Cryptography.Hashing.Algorithms.Analyzers.dll -> /home/coreclr/Tools/System.Security.Cryptography.Hashing.Algorithms.Analyzers.ni.dll
/home/coreclr/Tools/NuGet.Packaging.Core.dll -> /home/coreclr/Tools/NuGet.Packaging.Core.ni.dll
/home/coreclr/Tools/Microsoft.Build.Tasks.CodeAnalysis.dll -> /home/coreclr/Tools/Microsoft.Build.Tasks.CodeAnalysis.ni.dll
/home/coreclr/Tools/NuGet.DependencyResolver.Core.dll -> /home/coreclr/Tools/NuGet.DependencyResolver.Core.ni.dll
/home/coreclr/Tools/GenFacades.exe -> /home/coreclr/Tools/GenFacades.ni.exe
/home/coreclr/Tools/NuGet.Common.dll -> /home/coreclr/Tools/NuGet.Common.ni.dll
/home/coreclr/Tools/System.Composition.Convention.dll -> /home/coreclr/Tools/System.Composition.Convention.ni.dll
/home/coreclr/Tools/NuGet.Configuration.dll -> /home/coreclr/Tools/NuGet.Configuration.ni.dll
/home/coreclr/Tools/GenAPI.exe -> /home/coreclr/Tools/GenAPI.ni.exe
/home/coreclr/Tools/NuGet.Versioning.dll -> /home/coreclr/Tools/NuGet.Versioning.ni.dll
/home/coreclr/Tools/System.Composition.Hosting.dll -> /home/coreclr/Tools/System.Composition.Hosting.ni.dll
/home/coreclr/Tools/csc.exe -> /home/coreclr/Tools/csc.ni.exe
/home/coreclr/Tools/vbc.exe -> /home/coreclr/Tools/vbc.ni.exe
/home/coreclr/Tools/System.Composition.TypedParts.dll -> /home/coreclr/Tools/System.Composition.TypedParts.ni.dll
/home/coreclr/Tools/Microsoft.DotNet.Build.CloudTestTasks.dll -> /home/coreclr/Tools/Microsoft.DotNet.Build.CloudTestTasks.ni.dll
/home/coreclr/Tools/run.exe -> /home/coreclr/Tools/run.ni.exe
/home/coreclr/Tools/ApiCompat.exe -> /home/coreclr/Tools/ApiCompat.ni.exe
/home/coreclr/Tools/Microsoft.DotNet.VersionTools.dll -> /home/coreclr/Tools/Microsoft.DotNet.VersionTools.ni.dll
/home/coreclr/Tools/NuGet.Frameworks.dll -> /home/coreclr/Tools/NuGet.Frameworks.ni.dll
/home/coreclr/Tools/System.Xml.XPath.XmlDocument.dll -> /home/coreclr/Tools/System.Xml.XPath.XmlDocument.ni.dll
/home/coreclr/Tools/NuGet.ProjectModel.dll -> /home/coreclr/Tools/NuGet.ProjectModel.ni.dll
/home/coreclr/Tools/BclRewriter.exe -> /home/coreclr/Tools/BclRewriter.ni.exe
/home/coreclr/Tools/Microsoft.Cci.Extensions.dll -> /home/coreclr/Tools/Microsoft.Cci.Extensions.ni.dll
/home/coreclr/Tools/MSBuild.dll -> /home/coreclr/Tools/MSBuild.ni.dll
/home/coreclr/Tools/Microsoft.DotNet.Build.Tasks.dll -> /home/coreclr/Tools/Microsoft.DotNet.Build.Tasks.ni.dll
/home/coreclr/Tools/Microsoft.Build.Utilities.Core.dll -> /home/coreclr/Tools/Microsoft.Build.Utilities.Core.ni.dll
/home/coreclr/Tools/Microsoft.DotNet.Build.Tasks.Packaging.dll -> /home/coreclr/Tools/Microsoft.DotNet.Build.Tasks.Packaging.ni.dll
/home/coreclr/Tools/NuGet.Packaging.dll -> /home/coreclr/Tools/NuGet.Packaging.ni.dll
/home/coreclr/Tools/NuGet.Commands.dll -> /home/coreclr/Tools/NuGet.Commands.ni.dll
/home/coreclr/Tools/Microsoft.Build.Tasks.Core.dll -> /home/coreclr/Tools/Microsoft.Build.Tasks.Core.ni.dll
/home/coreclr/Tools/NuGet.Protocol.dll -> /home/coreclr/Tools/NuGet.Protocol.ni.dll
/home/coreclr/Tools/Newtonsoft.Json.dll -> /home/coreclr/Tools/Newtonsoft.Json.ni.dll
/home/coreclr/Tools/Microsoft.Build.dll -> /home/coreclr/Tools/Microsoft.Build.ni.dll
/home/coreclr/Tools/Microsoft.Cci.dll -> /home/coreclr/Tools/Microsoft.Cci.ni.dll
/home/coreclr/Tools/Microsoft.CodeAnalysis.dll -> /home/coreclr/Tools/Microsoft.CodeAnalysis.ni.dll
/home/coreclr/Tools/Microsoft.CodeAnalysis.CSharp.dll -> /home/coreclr/Tools/Microsoft.CodeAnalysis.CSharp.ni.dll
/home/coreclr/Tools/Microsoft.CodeAnalysis.VisualBasic.dll -> /home/coreclr/Tools/Microsoft.CodeAnalysis.VisualBasic.ni.dll
Crossgen finished.
Done initializing tools.
Laying out dynamically generated files consumed by the build system
Laying out dynamically generated Event Logging Test files
Generating Event Logging Tests
Laying out dynamically generated EventPipe Implementation
Laying out dynamically generated Event Logging Implementation of Lttng
Cleaning the temp folder of dynamically generated Event Logging files
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider with /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider_new
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider/lttng
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider/tests
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider/CMakeLists.txt
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventprovider/tracepointprovider
Cleaning the temp folder of dynamically generated EventPipe files
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe with /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe_new
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe/dotnetruntimeprivate.cpp
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe/dotnetruntimerundown.cpp
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe/eventpipehelpers.cpp
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe/CMakeLists.txt
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe/dotnetruntimestress.cpp
Updating /home/coreclr/bin/obj/Linux.x86.Debug/Generated/eventpipe/dotnetruntime.cpp
Commencing build of CoreCLR component for Linux.x86.Debug in /home/coreclr/bin/obj/Linux.x86.Debug
/home/coreclr
Running init-tools.sh
Tools are already initialized
Running: /home/coreclr/Tools/dotnetcli/dotnet /home/coreclr/Tools/run.exe /home/coreclr/config.json build -Project=/home/coreclr/build.proj -generateHeaderUnix -NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp -BuildArch=x86 -BuildType=Debug -BuildOS=Linux
Running: /home/coreclr/Tools/msbuild.sh /nologo /verbosity:minimal /clp:Summary /maxcpucount  /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log  /home/coreclr/build.proj /p:__BuildType=Debug /p:__BuildArch=x86 /p:__BuildOS=Linux  /t:GenerateVersionSourceFile /p:GenerateVersionSourceFile=true /p:NativeVersionSourceFile=/home/coreclr/bin/obj/Linux.x86.Debug/version.cpp /p:RestoreDefaultOptimizationDataPackage=false /p:UsePartialNGENOptimization=false /p:PortableBuild=true

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.77
Command execution succeeded.
Command successfully completed.
/home/coreclr/bin/obj/Linux.x86.Debug /home/coreclr
Invoking "/home/coreclr/src/pal/tools/gen-buildsys-clang.sh" "/home/coreclr" 3 8 x86 Debug  Include_Tests  -DCLR_CMAKE_TARGET_OS=Linux -DCLR_CMAKE_PACKAGES_DIR=/home/coreclr/packages -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_VERSION=99.99.99-master-20170712-0121 -DCLR_CMAKE_PGO_OPTIMIZE=1  -DSKIP_LLDBPLUGIN=true
Including tests directory in build.
loading initial cache file /home/coreclr/cross/x86/tryrun.cmake
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: /usr/bin/clang-3.8
-- Check for working C compiler: /usr/bin/clang-3.8 -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/clang-3.8" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/make" "cmTC_64b67/fast"

  /usr/bin/make -f CMakeFiles/cmTC_64b67.dir/build.make
  CMakeFiles/cmTC_64b67.dir/build

  make[1]: Entering directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_64b67.dir/testCCompiler.c.o

  /usr/bin/clang-3.8 -Wall -std=c11 -m32
  --sysroot=/home/coreclr/cross/rootfs/x86
  -Wno-error=unused-command-line-argument -o
  CMakeFiles/cmTC_64b67.dir/testCCompiler.c.o -c
  /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTC_64b67

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_64b67.dir/link.txt
  --verbose=1

  /usr/bin/clang-3.8 -Wall -std=c11 --sysroot=/home/coreclr/cross/rootfs/x86
  -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu
  -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32
  CMakeFiles/cmTC_64b67.dir/testCCompiler.c.o -o cmTC_64b67 -rdynamic

  /usr/bin/ld: cannot find -lgcc_s

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  CMakeFiles/cmTC_64b67.dir/build.make:97: recipe for target 'cmTC_64b67'
  failed

  make[1]: *** [cmTC_64b67] Error 1

  make[1]: Leaving directory
  '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'

  Makefile:126: recipe for target 'cmTC_64b67/fast' failed

  make: *** [cmTC_64b67/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:9 (project)

-- Configuring incomplete, errors occurred!
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeOutput.log".
See also "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeError.log".
/home/coreclr
Failed to generate CoreCLR component build project!

Contents of CMakeOutput.log:

The target system is: Linux -  - i686
The host system is: Linux - 4.9.36-moby - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /usr/bin/clang-3.8
Build flags:
Id flags:

The output was:
0

Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is Clang, found in "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/3.5.1/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /usr/bin/clang++-3.8
Build flags:
Id flags:

The output was:
0

Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is Clang, found in "/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/3.5.1/CompilerIdCXX/a.out"

Contents of CMakeError.log:

Determining if the C compiler works failed with the following output:
Change Dir: /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_64b67/fast"
/usr/bin/make -f CMakeFiles/cmTC_64b67.dir/build.make CMakeFiles/cmTC_64b67.dir/build
make[1]: Entering directory '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_64b67.dir/testCCompiler.c.o
/usr/bin/clang-3.8    -Wall -std=c11    -m32 --sysroot=/home/coreclr/cross/rootfs/x86 -Wno-error=unused-command-line-argument -o CMakeFiles/cmTC_64b67.dir/testCCompiler.c.o   -c /home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_64b67
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_64b67.dir/link.txt --verbose=1
/usr/bin/clang-3.8   -Wall -std=c11        --sysroot=/home/coreclr/cross/rootfs/x86 -B /home/coreclr/cross/rootfs/x86/usr/lib/gcc/i686-linux-gnu -L/home/coreclr/cross/rootfs/x86/lib/i386-linux-gnu -m32  CMakeFiles/cmTC_64b67.dir/testCCompiler.c.o  -o cmTC_64b67 -rdynamic
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_64b67.dir/build.make:97: recipe for target 'cmTC_64b67' failed
make[1]: *** [cmTC_64b67] Error 1
make[1]: Leaving directory '/home/coreclr/bin/obj/Linux.x86.Debug/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_64b67/fast' failed
make: *** [cmTC_64b67/fast] Error 2
parjong commented 7 years ago

Did you succeed in building rootfs? Could you check the files inside cross/rootfs/x86/?

kentcb commented 7 years ago

@parjong About 30 mins before you replied, I gave up on doing this in Docker and switched to VirtualBox. I got a lot further this time, but the build eventually failed with:

Scanning dependencies of target paltest_fopen_test4
[ 23%] Building CXX object src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeFiles/paltest_fopen_test4.dir/test4.cpp.o
[ 23%] Linking CXX executable paltest_fopen_test4
[ 23%] Building CXX object src/vm/wks/CMakeFiles/cee_wks.dir/__/threadsuspend.cpp.o
/usr/bin/ld: final link failed: No space left on device
clang: error: linker command failed with exit code 1 (use -v to see invocation)
src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeFiles/paltest_fopen_test4.dir/build.make:97: recipe for target 'src/pal/tests/palsuite/c_runtime/fopen/test4/paltest_fopen_test4' failed
make[2]: *** [src/pal/tests/palsuite/c_runtime/fopen/test4/paltest_fopen_test4] Error 1
CMakeFiles/Makefile2:4517: recipe for target 'src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeFiles/paltest_fopen_test4.dir/all' failed
make[1]: *** [src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeFiles/paltest_fopen_test4.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 23%] Building CXX object src/vm/wks/CMakeFiles/cee_wks.dir/__/typeparse.cpp.o
fatal error: error in backend: IO failure on output stream.
src/vm/wks/CMakeFiles/cee_wks.dir/build.make:4622: recipe for target 'src/vm/wks/CMakeFiles/cee_wks.dir/__/typeparse.cpp.o' failed
make[2]: *** [src/vm/wks/CMakeFiles/cee_wks.dir/__/typeparse.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
fatal error: error in backend: IO failure on output stream.
src/vm/wks/CMakeFiles/cee_wks.dir/build.make:4598: recipe for target 'src/vm/wks/CMakeFiles/cee_wks.dir/__/threadsuspend.cpp.o' failed
make[2]: *** [src/vm/wks/CMakeFiles/cee_wks.dir/__/threadsuspend.cpp.o] Error 1
CMakeFiles/Makefile2:62007: recipe for target 'src/vm/wks/CMakeFiles/cee_wks.dir/all' failed
make[1]: *** [src/vm/wks/CMakeFiles/cee_wks.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Failed to build CoreCLR component.

My VM HDD ran out of space! So I'm gonna start again, and report back again later 😫

kentcb commented 7 years ago

Yep, it worked! 🎉

Thanks a bunch for the help @parjong - didn't stand a chance without you.

For anyone following in my footsteps, the steps I took were:

IN VIRTUALBOX RUNNING UBUNTU 16.04: