Skip to content

[BUG] Can not compile native C programs on Ubuntu-x86 #92

@melonedo

Description

@melonedo

Describe the bug
The simple cmake -B build && cmake --build build method can not compile binary for native use. if specify -m32 flag, gcc can not compile a simple program; if we specify -mnative, the binary can not be used because "wrong ELF class: ELFCLASS64".

To Reproduce
This PR contains scripts to build such a binary (and fails).

Specifically, the build command: https://github.com/JuliaInterop/Clang.jl/blob/b76e9ae49b5ccb0316f9d1d61ece5a3ee545b258/test/test_bitfield.jl#L7-L25

I do not know how to put that into a workflow file however.

Expected behavior
Like any other platforms, compile native binary for testing.

Screenshots/Build logs
with -m32:

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /home/runner/.julia/packages/CMake/ULbyn/deps/usr/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/runner/work/Clang.jl/Clang.jl/test/build/bitfield/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_195b6/fast && /usr/bin/make -f CMakeFiles/cmTC_195b6.dir/build.make CMakeFiles/cmTC_195b6.dir/build
    make[1]: Entering directory '/home/runner/work/Clang.jl/Clang.jl/test/build/bitfield/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_195b6.dir/testCCompiler.c.o
    /usr/bin/cc   -m32    -o CMakeFiles/cmTC_195b6.dir/testCCompiler.c.o   -c /home/runner/work/Clang.jl/Clang.jl/test/build/bitfield/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_195b6
    /home/runner/.julia/packages/CMake/ULbyn/deps/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_195b6.dir/link.txt --verbose=1
    /usr/bin/cc -m32     CMakeFiles/cmTC_195b6.dir/testCCompiler.c.o  -o cmTC_195b6 
    /usr/bin/ld: cannot find Scrt1.o: No such file or directory
    /usr/bin/ld: cannot find crti.o: No such file or directory
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a when searching for -lgcc
    /usr/bin/ld: cannot find -lgcc
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a when searching for -lgcc
    /usr/bin/ld: cannot find -lgcc
    collect2: error: ld returned 1 exit status
    make[1]: *** [CMakeFiles/cmTC_195b6.dir/build.make:87: cmTC_195b6] Error 1
    make[1]: Leaving directory '/home/runner/work/Clang.jl/Clang.jl/test/build/bitfield/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_195b6/fast] Error 2

[snip]

-- Configuring incomplete, errors occurred!

with -mnative:

┌ Warning: Building libbitfield failed: ErrorException("could not load library \"/home/runner/work/Clang.jl/Clang.jl/test/build/bitfield/bin/libbitfield\"\n/home/runner/work/Clang.jl/Clang.jl/test/build/bitfield/bin/libbitfield.so: wrong ELF class: ELFCLASS64")
 Test Summary: |
└ @ Main ~/work/Clang.jl/Clang.jl/test/test_bitfield.jl:43

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions