Skip to content

fix: use Ubuntu 20.04 container for x86_64 Linux builds#20

Merged
cpunion merged 1 commit intogoplus:mainfrom
luoliwoshang:ci/order-glibc
Sep 5, 2025
Merged

fix: use Ubuntu 20.04 container for x86_64 Linux builds#20
cpunion merged 1 commit intogoplus:mainfrom
luoliwoshang:ci/order-glibc

Conversation

@luoliwoshang
Copy link
Copy Markdown
Member

@luoliwoshang luoliwoshang commented Sep 4, 2025

part of goplus/llgo#1265

This PR successfully resolves the GLIBC compatibility issues by using Ubuntu 20.04 container for x86_64 Linux builds.

Problem Solved

Previously, LLVM libraries built on Ubuntu 22.04 contained newer GLIBC symbols (2.33+) that caused linking errors:

undefined reference to `pthread_getname_np@GLIBC_2.34'
undefined reference to `lstat64@GLIBC_2.33'
undefined reference to `mallinfo2@GLIBC_2.33'

Solution

  • Use Ubuntu 20.04 container with GLIBC 2.31 for x86_64 builds
  • Install CMake 3.25.3 to meet LLVM build requirements
  • Only affects x86_64-linux-gnu target, other platforms unchanged

Build Verification

Successfully built and tested the LLGo compiler with the new LLVM libraries:

root@cppkg-5-77b864d675-2x9cg:~/llgo# ./esp-llgo 
llgo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python.

Usage:
  esp-llgo [command]

Available Commands:
  build       Compile packages and dependencies
  clean       Remove object files and cached files
  cmptest     Compile and run with llgo, compare result (stdout/stderr/exitcode) with go or llgo.expect; generate llgo.expect file if -gen is specified
  completion  Generate the autocompletion script for the specified shell
  get         Add dependencies to current module and install them
  help        Help about any command
  install     Compile and install packages and dependencies
  run         Compile and run Go program
  test        Compile and run Go test
  version     Print LLGo version

Flags:
  -h, --help   help for esp-llgo

Use "esp-llgo [command] --help" for more information about a command.

Compatibility Improvement

The generated LLVM libraries now use older, more compatible GLIBC symbols:

  • Maximum GLIBC version: 2.31
  • Compatible with CentOS 7, Ubuntu 18.04+, Debian 9+
  • Eliminates linking errors on older systems

ubuntu use this clang success

https://github.com/goplus/espressif-llvm-project-prebuilt/actions/runs/17471000739/artifacts/3930493964

export CGO_ENABLED=1
export CGO_CXXFLAGS="-std=c++17"
export CGO_CPPFLAGS="-I/root/llgo/esp-clang-glibc/esp-clang-glibc/include -I/root/llgo/esp-clang-glibc/esp-clang-glibc/include/llvm -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
export CGO_LDFLAGS="-L/root/llgo/esp-clang-glibc/esp-clang-glibc/lib -lLLVM-19 -Wl,-rpath,/root/llgo/esp-clang-glibc/esp-clang-glibc/lib"

go build -o esp-llgo -ldflags="-X github.com/goplus/llgo/internal/env.buildVersion=v1.0.0 -X github.com/goplus/llgo/internal/env.buildTime=2030.1.1 -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/root/llgo/esp-clang-glibc/esp-clang-glibc/bin/llvm-config" ./cmd/llgo
π
root@ubuntu24-llgo-homebrew-v1-0:~/llgo/_demo/emb# /root/llgo/bin/esp-llgo build -target esp32 -o test.bin .
cross compile: crosscompile.Export{CC:"/root/llgo/crosscompile/clang/bin/clang++", CCFLAGS:[]string{"--target=xtensa", "-mcpu=esp32"}, CFLAGS:[]string{"-Wno-override-module", "-Qunused-arguments", "-Wno-unused-command-line-argument", "--target=xtensa", "-Werror", "-fshort-enums", "-Wno-macro-redefined", "-fno-exceptions", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables", "-ffunction-sections", "-fdata-sections", "-I/root/.cache/llgo/crosscompile/newlib-esp32/newlib/libc/include", "-I/root/.cache/llgo/crosscompile/newlib-esp32/newlib", "-I/root/.cache/llgo/crosscompile/newlib-esp32/newlib/libc"}, LDFLAGS:[]string{"-mllvm", "-mcpu=esp32", "-mllvm", "-mattr=+atomctl,+bool,+clamps,+coprocessor,+debug,+density,+dfpaccel,+div32,+exception,+fp,+highpriinterrupts,+interrupt,+loop,+mac16,+memctl,+minmax,+miscsr,+mul32,+mul32high,+nsa,+prid,+regprotect,+rvector,+s32c1i,+sext,+threadptr,+timerint,+windowed", "-T", "targets/esp32.memory.elf.ld", "-L", "/root/llgo", "-nostdlib", "-L/root/.cache/llgo/crosscompile/newlib-esp32", "-lcrt0-xtensa", "-lgloss-xtensa", "-lc-xtensa", "-nostdlib", "-L/root/.cache/llgo/crosscompile/compiler-rt", "-lclang_builtins-xtensa", "--gc-sections"}, BuildTags:[]string{"xtensa", "baremetal", "linux", "arm", "esp32", "esp"}, GOOS:"linux", GOARCH:"arm", Libc:"newlib-esp32", Linker:"/root/llgo/crosscompile/clang/bin/ld.lld", ExtraFiles:[]string(nil), ClangRoot:"/root/llgo/crosscompile/clang", ClangBinPath:"", BinaryFormat:"esp32", FormatDetail:""}
root@ubuntu24-llgo-homebrew-v1-0:~/llgo/_demo/emb# ls
main.go  test.bin
root@ubuntu24-llgo-homebrew-v1-0:~/llgo/_demo/hello# /root/llgo/bin/esp-llgo run hello.go
hello world by println
hello world by fmt.Println
Hello world by c.Printf

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants