julia-actions / setup-julia

This action sets up a Julia environment for use in actions by downloading a specified version of Julia and adding it to PATH.
MIT License
93 stars 23 forks source link

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

Closed melonedo closed 2 years ago

melonedo commented 2 years ago

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
SaschaMann commented 2 years ago

This doesn't seem like a problem with setup-julia but rather with the GitHub Actions environment itself, since Julia seems to be installed just fine (otherwise it wouldn't even run the tests). It's probably better to ask on Zulip, Slack or Discourse. Feel free to reopen the issue if you think it's a bug with setup-julia but it doesn't look like one to me.


I don't know anything about cmake or gcc either, my best guess is that there might be a misunderstanding about the x86 flag. Setting the x86 architecture input in setup-julia installs Julia's 32-bit binaries. However, the architecture of the GitHub Actions runner/environment itself is x64.