Skip to content

binaryen is being built with inappropriate compiler flags for i586-unknown-linux-gnu host #49267

Closed

Description

@kepstin

I've been trying to get an i586-unknown-linux-gnu build of rustc 1.24.1 going for a while, and I've gotten close, but the final rustc binary is crashing with an illegal instruction:

Program received signal SIGILL, Illegal instruction.
0xb6dbca15 in cashew::IStringSet::IStringSet(char const*) ()
   from /home/cwalton/rust-1.24.1-i586-unknown-linux-gnu-stage0/bin/../lib/../lib/librustc_trans-1401e33888f16318.so
(gdb) bt
#0  0xb6dbca15 in cashew::IStringSet::IStringSet(char const*) ()
   from /home/cwalton/rust-1.24.1-i586-unknown-linux-gnu-stage0/bin/../lib/../lib/librustc_trans-1401e33888f16318.so
#1  0xb6bf93cc in _GLOBAL__sub_I_parser.cpp ()
   from /home/cwalton/rust-1.24.1-i586-unknown-linux-gnu-stage0/bin/../lib/../lib/librustc_trans-1401e33888f16318.so
#2  0xb7fe827e in call_init.part () from /lib/ld-linux.so.2
#3  0xb7fe8375 in _dl_init () from /lib/ld-linux.so.2
#4  0xb7fd9aff in _dl_start_user () from /lib/ld-linux.so.2

When looking into it, this particular piece of code is from the native binaryen library. From the build log build/i586-unknown-linux-gnu/stage0-rustc/i586-unknown-linux-gnu/release/build/rustc_binaryen-b307d012dc0782fb/output:

running: "cmake" "/home/cwalton/rustc-1.24.1-src/src/librustc_binaryen/../binaryen" "-DBUILD_STATIC_LIB=ON" "-DCMAKE_INSTALL_PREFIX=/home/cwalton/rustc-1.24.1-src/build/i586-unknown-linux-gnu/stage0-rustc/i586-unknown-linux-gnu/release/build/rustc_binaryen-b307d012dc0782fb/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -ffunction-sections -fdata-sections -fPIC -m32 -march=pentium -m32 -march=pentium" "-DCMAKE_C_COMPILER=/usr/i586-pc-linux-gnu/gcc-bin/7.3.0/i586-pc-linux-gnu-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -ffunction-sections -fdata-sections -fPIC -m32 -march=pentium -m32 -march=pentium" "-DCMAKE_CXX_COMPILER=/usr/i586-pc-linux-gnu/gcc-bin/7.3.0/i586-pc-linux-gnu-c++" "-DCMAKE_BUILD_TYPE=Release"
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/i586-pc-linux-gnu/gcc-bin/7.3.0/i586-pc-linux-gnu-gcc
-- Check for working C compiler: /usr/i586-pc-linux-gnu/gcc-bin/7.3.0/i586-pc-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/i586-pc-linux-gnu/gcc-bin/7.3.0/i586-pc-linux-gnu-c++
-- Check for working CXX compiler: /usr/i586-pc-linux-gnu/gcc-bin/7.3.0/i586-pc-linux-gnu-c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Building with -std=c++11
-- Building for platform i386
-- Building with -msse2
-- Building with -mfpmath=sse
-- Building with -Wall
-- Building with -Werror
-- Building with -Wextra
-- Building with -Wno-unused-parameter
-- Building with -fno-omit-frame-pointer
-- Building with -fPIC
-- Building with -O2
-- Building with -UNDEBUG
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cwalton/rustc-1.24.1-src/build/i586-unknown-linux-gnu/stage0-rustc/i586-unknown-linux-gnu/release/build/rustc_binaryen-b307d012dc0782fb/out/build

It's building with the compiler options -msse2 -mfpmath=sse which should not be used on the i586 target.

Activity

  1. plugwash commented on Mar 22, 2018

    @plugwash

    Just a note, the offending code seems to be in src/binaryen/CMakeLists.txt

  2. kennytm commented on Mar 23, 2018

    @kennytm
    Member

    Note that binaryen has been removed in Rust 1.26 (by #48125), which will enter beta next week.

  3. kepstin commented on Mar 23, 2018

    @kepstin
    Author

    After looking into this a bit further, the binaryen folks have force-enabled sse2 with the note "wasm doesn't allow for x87 floating point math". I suppose this is referring to issues with precision/rounding when doing calculations with constants while compiling to wasm? It's unclear how much of a problem this might actually be.

    If disabling sse operations in binaryen isn't an option, then the only way to get an i586 rustc build working again would be to allow disabling binaryen and the wasm target.

    Edit: Missed a comment - the binaryen removal in 1.26 should solve this issue.

  4. kepstin commented on Mar 23, 2018

    @kepstin
    Author

    I've cross-compiled a nightly rustc from after the #48125 merge, and I've confirmed that the result is able to bootstrap nightly rustc on my i586 box. I'm gonna consider this issue fixed - looking forwards to the beta release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions