runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Linux/ARM: Build Break with -O3 in release build

Open leemgs opened this issue 10 years ago • 5 comments

Here is error message while building CoreCLR source in release-build (with -O3 optimization flag) for Linux/ARM environemt.

geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ time ./build.sh arm-softfp cross release clean clang3.6  | tee mybuild-workstation.txt
                        . . . . UPPER OMISSION . . . 
/home/geunsik/dotnet/coreclr.20160608/bin/obj/Linux.arm-softfp.Release/src/dlls/dbgshim/libdbgshim.so.dbg
../../coreclr/hosts/unixcoreruncommon/libunixcoreruncommon.a(coreruncommon.cpp.o): In function `std::string::_M_check(unsigned int, char const*) const':
/home/geunsik/gbsroot/BUILD-ROOTS/scratch.armv7l.0/usr/lib/gcc/armv7l-linux-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
/home/geunsik/gbsroot/BUILD-ROOTS/scratch.armv7l.0/usr/lib/gcc/armv7l-linux-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
/home/geunsik/gbsroot/BUILD-ROOTS/scratch.armv7l.0/usr/lib/gcc/armv7l-linux-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/ildasm/exe/ildasm] Error 1
make[1]: *** [src/ildasm/exe/CMakeFiles/ildasm.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
../coreclr/hosts/unixcoreruncommon/libunixcoreruncommon.a(coreruncommon.cpp.o): In function `std::string::_M_check(unsigned int, char const*) const':
/home/geunsik/gbsroot/BUILD-ROOTS/scratch.armv7l.0/usr/lib/gcc/armv7l-linux-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
/home/geunsik/gbsroot/BUILD-ROOTS/scratch.armv7l.0/usr/lib/gcc/armv7l-linux-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
/home/geunsik/gbsroot/BUILD-ROOTS/scratch.armv7l.0/usr/lib/gcc/armv7l-linux-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/ilasm/ilasm] Error 1
make[1]: *** [src/ilasm/CMakeFiles/ilasm.dir/all] Error 2
[ 93%] Built target dbgshim
/home/geunsik/dotnet/coreclr.20160608/bin/obj/Linux.arm-softfp.Release/src/jit/standalone/libclrjit.so.dbg
[ 96%] Built target clrjit
/home/geunsik/dotnet/coreclr.20160608/bin/obj/Linux.arm-softfp.Release/src/jit/protojit/libprotojit.so.dbg
[ 99%] Built target protojita
/home/geunsik/dotnet/coreclr.20160608/bin/obj/Linux.arm-softfp.Release/src/tools/crossgen/crossgen.dbg
[ 99%] Built target crossgen
/home/geunsik/dotnet/coreclr.20160608/bin/obj/Linux.arm-softfp.Release/src/inc/dactablerva.h
/home/geunsik/dotnet/coreclr.20160608/bin/obj/Linux.arm-softfp.Release/src/dlls/mscoree/coreclr/libcoreclr.so.dbg
[ 99%] Built target coreclr
make: *** [all] Error 2
Failed to build coreclr components.
Command exited with non-zero status 1
132.72user 33.30system 0:33.12elapsed 501%CPU (0avgtext+0avgdata 485416maxresident)k
0inputs+3998864outputs (0major+8865476minor)pagefaults 0swaps
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ 

leemgs avatar Jun 08 '16 06:06 leemgs

Below is the version that I have used to compile coreclr

  • GCC version: 4.8.4-2
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ gcc --version
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • Using my standard c++ library in --sys-root
    • https://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_3.html#SEC17
diff --git a/cross/arm-softfp/toolchain.cmake b/cross/arm-softfp/toolchain.cmake
index 407ab53..ee5a4a3 100644
--- a/cross/arm-softfp/toolchain.cmake
+++ b/cross/arm-softfp/toolchain.cmake
@@ -6,6 +6,7 @@ set(CMAKE_SYSTEM_PROCESSOR armv7l)

 ## Specify the toolchain
 set(TOOLCHAIN "arm-linux-gnueabi")
+set(TOOLCHAIN_CUSTOM "armv7l-xxxx-linux-gnueabi/4.9.2")
 set(TOOLCHAIN_PREFIX ${TOOLCHAIN}-)
 #set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
 #set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
@@ -20,8 +21,8 @@ add_compile_options(-mfpu=vfpv3)
 add_compile_options(--sysroot=${CROSS_ROOTFS})

 set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -target ${TOOLCHAIN}")
-set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -B${CROSS_ROOTFS}/usr/lib/gcc/${TOOLCHAIN}")
-set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -L${CROSS_ROOTFS}/lib/${TOOLCHAIN}")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -B${CROSS_ROOTFS}/usr/lib/gcc/${TOOLCHAIN_CUSTOM}")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -L${CROSS_ROOTFS}/usr/lib/gcc/${TOOLCHAIN_CUSTOM}")
 set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} --sysroot=${CROSS_ROOTFS}")
  • Clang/LLVM version
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ dpkg -l | grep clang
ii  clang-3.6                                                   1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        C, C++ and Objective-C compiler (LLVM based)
ii  libclang-common-3.6-dev                                     1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        clang library - Common development package
ii  libclang1-3.6:amd64                                         1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        C interface to the clang library
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ dpkg -l | grep llvm
ii  libllvm3.5:amd64                                            1:3.5-4ubuntu2~trusty2                              amd64        Modular compiler and toolchain technologies, runtime library
ii  libllvm3.6:amd64                                            1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        Modular compiler and toolchain technologies, runtime library
ii  llvm-3.6                                                    1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        Modular compiler and toolchain technologies
ii  llvm-3.6-dev                                                1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        Modular compiler and toolchain technologies, libraries and headers
ii  llvm-3.6-runtime                                            1:3.6-2ubuntu1~trusty1ubuntu3                       amd64        Modular compiler and toolchain technologies, IR interpreter
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ 

leemgs avatar Jun 08 '16 06:06 leemgs

This build error results from the absence of the appropriated standard C++ library. In order to resolve this issue, Please, update (or install) libstdc++-4.8-dev:amd64 and libstdc++6:amd64.

ubuntu14.04@x64$> sudo apt-get install libstdc++-4.8-dev:amd64 libstdc++6:amd64 ( or target$> sudo apt-get instal ....... )

  • Here is detail information of the two packages.
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ dpkg -l | grep libstdc++
ii  libstdc++-4.8-dev:amd64                                     4.8.4-2ubuntu1~14.04.3                              amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++6:amd64                                            4.8.4-2ubuntu1~14.04.3                              amd64        GNU Standard C++ Library v3
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ 
  • The location of the basig_string header file:
geunsik@DXL-Workstation:~/dotnet/coreclr.20160608$ dpkg -L libstdc++-4.8-dev:amd64 | grep basic_string
/usr/include/c++/4.8/bits/basic_string.tcc
/usr/include/c++/4.8/bits/basic_string.h

leemgs avatar Jun 08 '16 06:06 leemgs

This issue is related to the PR https://github.com/dotnet/coreclr/pull/5598.

Fixed.

leemgs avatar Jun 08 '16 06:06 leemgs

\CC: @myungjoo , @parjong , @prajwal-aithal

leemgs avatar Jun 08 '16 06:06 leemgs

I have such issue with release CoreCLR cross build for ARM soft FP with emulator rootfs. I receive the following error building with patched clang3.6:

../../coreclr/hosts/unixcoreruncommon/libunixcoreruncommon.a(coreruncommon.cpp.o): In function `std::string::_M_check(unsigned int, char const*) const':
/CROSS-ROOTFS/emulator/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
/CROSS-ROOTFS/emulator/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
/CROSS-ROOTFS/emulator/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/bits/basic_string.h:324: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'

However build is succesful if I use unmodified upstream clang-3.8 or clang-3.5.

I suppose my Linux box has all necessary libraries:

# dpkg -l | grep libstdc++
ii  libstdc++-4.8-dev:amd64                            4.8.4-2ubuntu1~14.04.3                amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++-4.8-dev-arm64-cross                      4.8.4-2ubuntu1~14.04.1cross0.11.2     all          GNU Standard C++ Library v3 (development files)
ii  libstdc++-4.8-dev-armhf-cross                      4.8.4-2ubuntu1~14.04.1cross0.11.2     all          GNU Standard C++ Library v3 (development files)
ii  libstdc++6:amd64                                   4.8.4-2ubuntu1~14.04.3                amd64        GNU Standard C++ Library v3
ii  libstdc++6-4.7-dev-armel-cross                     4.7.3-12ubuntu1cross1.85              all          GNU Standard C++ Library v3 (development files)
ii  libstdc++6-4.7-dev-armhf-cross                     4.7.3-11ubuntu1cross1.85              all          GNU Standard C++ Library v3 (development files)
ii  libstdc++6-arm64-cross                             4.8.4-2ubuntu1~14.04.1cross0.11.2     all          GNU Standard C++ Library v3
ii  libstdc++6-armel-cross                             4.7.3-12ubuntu1cross1.85              all          GNU Standard C++ Library v3
ii  libstdc++6-armhf-cross                             4.8.4-2ubuntu1~14.04.1cross0.11.2     all          GNU Standard C++ Library v3
# dpkg -l | grep clang
ii  clang-3.5                                          1:3.5-4ubuntu2~trusty2                amd64        C, C++ and Objective-C compiler (LLVM based)
ii  clang-3.6                                          1:3.6-2ubuntu1~trusty1ubuntu3         amd64        C, C++ and Objective-C compiler (LLVM based)
ii  libclang-common-3.5-dev                            1:3.5-4ubuntu2~trusty2                amd64        clang library - Common development package
ii  libclang-common-3.6-dev                            1:3.6-2ubuntu1~trusty1ubuntu3         amd64        clang library - Common development package
ii  libclang-common-3.8-dev                            1:3.8~svn262614-1~exp1                amd64        clang library - Common development package
rc  libclang1-3.4:amd64                                1:3.4-1ubuntu3                        amd64        C interface to the clang library
ii  libclang1-3.5:amd64                                1:3.5-4ubuntu2~trusty2                amd64        C interface to the clang library
ii  libclang1-3.6:amd64                                1:3.6-2ubuntu1~trusty1ubuntu3         amd64        C interface to the clang library

The issue happens with release build only (debug build is successful). I suppose that my cross build config lacks some necessary option. I use /dotnet/setenv/coreclr_cross.patch from emulator rootfs for cross build.

mkborg avatar Jul 29 '16 08:07 mkborg