musl-based linux distro support (#2577)

* added switch statement to link musl-based linux distros to ld-musl-x86-64.so.2

* Update linker.c

/lib/ld-musl-x86-64.so.1 is musl's ld so. My bad

* don't need ENV_MUSLEABI.* in the switch for x86_64

* typo

* Added a CI test for an Alpine Linux container

* Update main.yml

Forgot to have bundle_output job use `env.LLVM_RELEASE_VERSION_ALPINEv3_22`.

* Added env.LLVM_RELEASE_VERSION_ALPINEv3_22 to `upload artifacts`

* changed bundle name to c3-musl-${{matrix,build_type}}.tar.gz

* Undid an accidental name change in build-linux-ubuntu22

* Update main.yml

sudo doesn't exist in alpine by default, and runs in root by default.

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

`--linker=builtin` fails because it forces search of `/lib64/ld-linux-x86-64.so.2`. lib64 doesn't exist on musl unless created as a symlink, and the appropriate so is /lib/ld-musl-<arch>.so.1

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

make isn't in alpine by default. added it in for risc-v example.

* gcc-riscv-none-elf is alpine's package

* using realpath for c3c over using relative pathing

* Have to use relative path for arguments in compiler test

* added --linker=builtin to

* Added linux-musl-<arch> targets

* Added more ld targets for glibc

* set both testproject libs as folders until they behave better

* added linux-musl-x64 target to clib2

* added riscv targets for ld-linux

* ubuntu doesn't have ld in /lib, but solely in /lib64?

* Make MUSL distinct from the target.

* Fix default in project schema

* Fix define

* Fix manifests.

* Update main.yml

add --linux-libc flag for builtin linking

* Grammar refresh

* Update releasenotes.

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
DylanDoesProgramming
2025-12-02 18:42:36 -05:00
committed by GitHub
parent ce0ab62c78
commit ccffa03de2
20 changed files with 397 additions and 1382 deletions

View File

@@ -6,10 +6,12 @@ hello.a: $(SRCS_C3)
$(C3C_PATH)c3c -g --use-stdlib=no --no-entry --target elf-riscv32 static-lib $(SRCS_C3)
start.o: start.s
riscv64-unknown-elf-as -g -march=rv32i -mabi=ilp32 -misa-spec=20191213 -o start.o start.s
riscv64-unknown-elf-as -g -march=rv32i -mabi=ilp32 -misa-spec=20191213 -o start.o start.s \
|| riscv-none-elf-as -g -march=rv32i -mabi=ilp32 -misa-spec=20191213 -o start.o start.s
hello.elf: hello.a start.o baremetal.ld
riscv64-unknown-elf-ld -T baremetal.ld -m elf32lriscv -o hello.elf hello.a start.o
riscv64-unknown-elf-ld -T baremetal.ld -m elf32lriscv -o hello.elf hello.a start.o \
|| riscv-none-elf-ld -T baremetal.ld -m elf32lriscv -o hello.elf hello.a start.o
run: hello.elf
qemu-system-riscv32 -nographic -serial mon:stdio -machine virt -semihosting -bios hello.elf

File diff suppressed because it is too large Load Diff

View File

@@ -199,6 +199,15 @@
"description": "Include the standard library.",
"default": true
},
"linux-libc": {
"type": "string",
"description": "Set the libc to use for Linux.",
"enum": [
"gnu",
"musl"
],
"default": "gnu"
},
"x86cpu": {
"type": "string",
"description": "Set general level of x64 cpu.",

View File

@@ -1,15 +1,19 @@
{
"provides" : "clib",
"c-sources" : ["hello2.c", "whitespace test.c"],
"targets" : {
"macos-x64" : {
},
"macos-aarch64" : {},
"linux-x64" : {
{
"provides": "clib",
"c-sources": [
"hello2.c",
"whitespace test.c"
],
"targets": {
"macos-x64": {},
"macos-aarch64": {},
"linux-x64": {
"cflags": "-fPIE"
},
"windows-x64" : {
"c-include-dirs": ["C:\\"]
"windows-x64": {
"c-include-dirs": [
"C:\\"
]
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,3 @@
module clib2;
extern fn void hello_from_c_zip();

View File

@@ -0,0 +1,5 @@
#include <stdio.h>
void hello_from_c_zip(void)
{
puts("Hello from C Zip!");
}

View File

@@ -0,0 +1,14 @@
{
"provides": "clib2",
"c-sources": [
"hello.c"
],
"targets": {
"macos-x64": {},
"macos-aarch64": {},
"linux-x64": {
"cflags-override": "-fPIE"
},
"windows-x64": {}
}
}