gba-llvm-devkit icon indicating copy to clipboard operation
gba-llvm-devkit copied to clipboard

attempt to get this repo working again

Open walkingeyerobot opened this issue 7 months ago • 3 comments

This isn't ready for merging yet. I'm still having trouble getting everything working. I'm hoping you can give me a nudge in the right direction here.

The repo at https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm was deprecated a few months ago in favor of https://github.com/arm/arm-toolchain/tree/arm-software/arm-software/embedded. The latter also defines read_repo_version and VERSIONS_JSON which was causing some conflicts, so for now to get things moving I just renamed the ones in this repo.

My best guess is the undefined symbols in crt0.o are supposed to be defined in common/gba_crt0.s or in some other assembly file.

Here's the build error I'm getting:

[2/5] Performing configure step for 'gba_sources'
FAILED: gba_sources/src/gba_sources-stamp/gba_sources-configure /home/mitch/repos/gba-llvm-devkit/build/gba_sources/src/gba_sources-stamp/gba_sources-configure
cd /home/mitch/repos/gba-llvm-devkit/build/gba_sources/src/gba_sources-build && /usr/local/bin/cmake -DLLVM_BINARY_DIR=/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm -DCMAKE_AR=/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/llvm-ar -DCMAKE_ASM_COMPILER_TARGET=armv4t-none-eabi "-DCMAKE_ASM_FLAGS=-march=armv4t -fno-exceptions -fno-rtti --sysroot /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang++ -DCMAKE_CXX_COMPILER_TARGET=armv4t-none-eabi "-DCMAKE_CXX_FLAGS=-march=armv4t -fno-exceptions -fno-rtti --sysroot /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t" -DCMAKE_C_COMPILER=/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang -DCMAKE_C_COMPILER_TARGET=armv4t-none-eabi "-DCMAKE_C_FLAGS=-march=armv4t -fno-exceptions -fno-rtti --sysroot /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t" -DCMAKE_INSTALL_PREFIX=/home/mitch/repos/gba-llvm-devkit/build/gba_sources -DCMAKE_NM=/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/llvm-nm -DCMAKE_RANLIB=/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/llvm-ranlib -DCMAKE_SYSTEM_NAME=Generic -GNinja -S /home/mitch/repos/gba-llvm-devkit/common -B /home/mitch/repos/gba-llvm-devkit/build/gba_sources/src/gba_sources-build && /usr/local/bin/cmake -E touch /home/mitch/repos/gba-llvm-devkit/build/gba_sources/src/gba_sources-stamp/gba_sources-configure
-- The C compiler identification is Clang 21.0.0
-- The CXX compiler identification is Clang 21.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang
-- Check for working C compiler: /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang - broken
CMake Error at /usr/local/share/cmake-4.1/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/mitch/repos/gba-llvm-devkit/build/gba_sources/src/gba_sources-build/CMakeFiles/CMakeScratch/TryCompile-GseoW9'

    Run Build Command(s): /home/mitch/bin/ninja -v cmTC_4c080
    [1/2] /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang --target=armv4t-none-eabi   -march=armv4t -fno-exceptions -fno-rtti --sysroot /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t -MD -MT CMakeFiles/cmTC_4c080.dir/testCCompiler.c.obj -MF CMakeFiles/cmTC_4c080.dir/testCCompiler.c.obj.d -o CMakeFiles/cmTC_4c080.dir/testCCompiler.c.obj -c /home/mitch/repos/gba-llvm-devkit/build/gba_sources/src/gba_sources-build/CMakeFiles/CMakeScratch/TryCompile-GseoW9/testCCompiler.c
    [2/2] : && /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang --target=armv4t-none-eabi -march=armv4t -fno-exceptions -fno-rtti --sysroot /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t  CMakeFiles/cmTC_4c080.dir/testCCompiler.c.obj -o cmTC_4c080   && :
    FAILED: cmTC_4c080
    : && /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/bin/clang --target=armv4t-none-eabi -march=armv4t -fno-exceptions -fno-rtti --sysroot /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t  CMakeFiles/cmTC_4c080.dir/testCCompiler.c.obj -o cmTC_4c080   && :
    ld.lld: error: undefined symbol: __data_start
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_cstart)

    ld.lld: error: undefined symbol: __data_source
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_cstart)

    ld.lld: error: undefined symbol: __data_size
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_cstart)

    ld.lld: error: undefined symbol: __bss_size
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_cstart)

    ld.lld: error: undefined symbol: __tls_base
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_cstart)

    ld.lld: error: undefined symbol: __stack
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_start)
    >>> referenced by crt0.c
    >>>               /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/crt0.o:(_set_stacks)

    ld.lld: error: undefined symbol: __arm32_tls_tcb_offset
    >>> referenced by set_tls.c
    >>>               libc_picolib_machine_arm_set_tls.c.o:(_set_tls) in archive /home/mitch/repos/gba-llvm-devkit/build/build/_deps/bmt-src/arm-software/embedded/llvm/lib/clang-runtimes/arm-none-eabi/armv4t/lib/libc.a
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

walkingeyerobot avatar Jul 07 '25 07:07 walkingeyerobot

Hi! Thanks for looking into this :)

That CMake check uses the crt0.o file from picolibc, however that file is meant to be used with one of the picolibc linker scripts which will actually define those symbols. So we should either wrangle CMake to use the picolibc crt0.o file with the picolibc linker script, or our compiled gba_crt0.o file with our gba linker script. The two pairs are mutually exclusive.

stuij avatar Jul 08 '25 22:07 stuij

Thanks very much for the response! That should be enough for me to go on. I'll hopefully have some time this weekend to take a crack at it.

walkingeyerobot avatar Jul 09 '25 04:07 walkingeyerobot

btw what I think is probably going on is that clang automatically picks up the crt0 file, but we don't supply the linker file on the cmdline.

stuij avatar Jul 11 '25 18:07 stuij