Skip to content

Commit b4d193b

Browse files
authored
Merge pull request odin-lang#5904 from laytan/ubuntu-arm-ci
Ubuntu arm ci and posix fixes
2 parents 58a66c3 + 7aeed8b commit b4d193b

File tree

10 files changed

+59
-25
lines changed

10 files changed

+59
-25
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
os: [macos-15-intel, macos-latest, ubuntu-latest]
77+
os: [macos-15-intel, macos-latest, ubuntu-latest, ubuntu-24.04-arm]
7878
runs-on: ${{ matrix.os }}
79-
name: ${{ matrix.os == 'macos-latest' && 'MacOS ARM' || (matrix.os == 'macos-15-intel' && 'MacOS Intel') || (matrix.os == 'ubuntu-latest' && 'Ubuntu') }} Build, Check, and Test
79+
name: ${{ matrix.os == 'macos-latest' && 'MacOS ARM' || (matrix.os == 'macos-15-intel' && 'MacOS Intel') || (matrix.os == 'ubuntu-latest' && 'Ubuntu') || (matrix.os == 'ubuntu-24.04-arm' && 'Ubuntu ARM') }} Build, Check, and Test
8080
timeout-minutes: 15
8181
steps:
8282

@@ -97,19 +97,21 @@ jobs:
9797
echo "$(brew --prefix llvm@20)/bin" >> $GITHUB_PATH
9898
9999
- name: Download LLVM (Ubuntu)
100-
if: matrix.os == 'ubuntu-latest'
100+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm'
101101
run: |
102102
wget https://apt.llvm.org/llvm.sh
103103
chmod +x llvm.sh
104104
sudo ./llvm.sh 20
105105
echo "/usr/lib/llvm-20/bin" >> $GITHUB_PATH
106-
107106
- name: Build Odin
108107
run: ./build_odin.sh release
109108
- name: Odin version
110109
run: ./odin version
111110
- name: Odin report
112111
run: ./odin report
112+
- name: Get needed vendor libs
113+
if: matrix.os == 'ubuntu-24.04-arm'
114+
run: sudo apt-get install -y liblua5.4-dev
113115
- name: Compile needed Vendor
114116
run: |
115117
make -C vendor/stb/src

core/sys/posix/pthread.odin

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,16 @@ when ODIN_OS == .Darwin {
632632

633633
pthread_t :: distinct c.ulong
634634

635+
when ODIN_ARCH == .arm64 {
636+
@(private)
637+
__SIZEOF_PTHREAD_ATTR_T :: 64
638+
} else {
639+
@(private)
640+
__SIZEOF_PTHREAD_ATTR_T :: 56
641+
}
642+
635643
pthread_attr_t :: struct #raw_union {
636-
__size: [56]c.char, // NOTE: may be smaller depending on libc or arch, but never larger.
644+
__size: [__SIZEOF_PTHREAD_ATTR_T]c.char,
637645
__align: c.long,
638646
}
639647

core/sys/posix/sys_sem.odin

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ foreign lib {
1818
[[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/semctl.html ]]
1919
*/
2020
@(link_name=LSEMCTL)
21-
semctl :: proc(semid: FD, semnum: c.int, cmd: Sem_Cmd, arg: ^semun = nil) -> c.int ---
21+
semctl :: proc(semid: FD, semnum: c.int, cmd: Sem_Cmd, #c_vararg args: ..semun) -> c.int ---
2222

2323
/*
2424
Returns the semaphore identifier associated with key.
@@ -39,6 +39,9 @@ foreign lib {
3939
}
4040

4141
Sem_Cmd :: enum c.int {
42+
RMID = IPC_RMID,
43+
SET = IPC_SET,
44+
STAT = IPC_STAT,
4245
// Returns the value of semncnt.
4346
GETNCNT = GETNCNT,
4447
// Returns the value of sempid.
@@ -137,15 +140,26 @@ when ODIN_OS == .Darwin || ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS
137140
SETVAL :: 16
138141
SETALL :: 17
139142

140-
semid_ds :: struct {
141-
sem_perm: ipc_perm, // [PSX] operation permission structure
142-
sem_otime: time_t, // [PSX] last semop()
143-
__sem_otime_high: c.ulong,
144-
sem_ctime: time_t, // [PSX] last time changed by semctl()
145-
__sem_ctime_high: c.ulong,
146-
sem_nsems: c.ulong, // [PSX] number of semaphores in set
147-
__glibc_reserved3: c.ulong,
148-
__glibc_reserved4: c.ulong,
143+
when ODIN_ARCH == .arm64 {
144+
semid_ds :: struct {
145+
sem_perm: ipc_perm, // [PSX] operation permission structure
146+
sem_otime: time_t, // [PSX] last semop()
147+
sem_ctime: time_t, // [PSX] last time changed by semctl()
148+
sem_nsems: c.ulong, // [PSX] number of semaphores in set
149+
__glibc_reserved3: c.ulong,
150+
__glibc_reserved4: c.ulong,
151+
}
152+
} else {
153+
semid_ds :: struct {
154+
sem_perm: ipc_perm, // [PSX] operation permission structure
155+
sem_otime: time_t, // [PSX] last semop()
156+
__sem_otime_high: c.ulong,
157+
sem_ctime: time_t, // [PSX] last time changed by semctl()
158+
__sem_ctime_high: c.ulong,
159+
sem_nsems: c.ulong, // [PSX] number of semaphores in set
160+
__glibc_reserved3: c.ulong,
161+
__glibc_reserved4: c.ulong,
162+
}
149163
}
150164

151165
sembuf :: struct {

tests/core/sys/posix/structs/structs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ int main(int argc, char *argv[])
102102
printf("iovec %zu %zu\n", sizeof(struct iovec), _Alignof(struct iovec));
103103

104104
printf("semid_ds %zu %zu\n", sizeof(struct semid_ds), _Alignof(struct semid_ds));
105+
printf("semid_ds.sem_perm %zu\n", offsetof(struct semid_ds, sem_perm));
106+
printf("semid_ds.sem_otime %zu\n", offsetof(struct semid_ds, sem_otime));
107+
printf("semid_ds.sem_ctime %zu\n", offsetof(struct semid_ds, sem_ctime));
108+
printf("semid_ds.sem_nsems %zu\n", offsetof(struct semid_ds, sem_nsems));
109+
105110
printf("sembuf %zu %zu\n", sizeof(struct sembuf), _Alignof(struct sembuf));
106111

107112
printf("itimerval %zu %zu\n", sizeof(struct itimerval), _Alignof(struct itimerval));

tests/core/sys/posix/structs/structs.odin

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ main :: proc() {
6868
fmt.println("iovec", size_of(posix.iovec), align_of(posix.iovec))
6969

7070
fmt.println("semid_ds", size_of(posix.semid_ds), align_of(posix.semid_ds))
71+
fmt.println("semid_ds.sem_perm", offset_of(posix.semid_ds, sem_perm))
72+
fmt.println("semid_ds.sem_otime", offset_of(posix.semid_ds, sem_otime))
73+
fmt.println("semid_ds.sem_ctime", offset_of(posix.semid_ds, sem_ctime))
74+
fmt.println("semid_ds.sem_nsems", offset_of(posix.semid_ds, sem_nsems))
75+
7176
fmt.println("sembuf", size_of(posix.sembuf), align_of(posix.sembuf))
7277

7378
fmt.println("itimerval", size_of(posix.itimerval), align_of(posix.itimerval))

tests/internal/test_pow.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pow_test :: proc(t: ^testing.T) {
3333
_v2 := transmute(u16)v2
3434
_v1 := transmute(u16)v1
3535

36-
when ODIN_OS == .Darwin && ODIN_ARCH == .arm64 {
36+
when ODIN_ARCH == .arm64 {
3737
if exp == -25 {
38-
log.info("skipping known test failure on darwin+arm64, Expected math.pow2_f16(-25) == math.pow(2, -25) (= 0000), got 0001")
38+
log.info("skipping known test failure on arm64, Expected math.pow2_f16(-25) == math.pow(2, -25) (= 0000), got 0001")
3939
_v2 = 0
4040
}
4141
}

vendor/lua/5.1/lua.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ when LUA_SHARED {
1414
when ODIN_OS == .Windows {
1515
// Does nothing special on windows
1616
foreign import lib "windows/lua5.1.dll.lib"
17-
} else when ODIN_OS == .Linux {
17+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
1818
foreign import lib "linux/liblua5.1.so"
1919
} else {
2020
foreign import lib "system:lua5.1"
2121
}
2222
} else {
2323
when ODIN_OS == .Windows {
2424
foreign import lib "windows/lua5.1.dll.lib"
25-
} else when ODIN_OS == .Linux {
25+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
2626
foreign import lib "linux/liblua5.1.a"
2727
} else {
2828
foreign import lib "system:lua5.1"

vendor/lua/5.2/lua.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ when LUA_SHARED {
1414
when ODIN_OS == .Windows {
1515
// Does nothing special on windows
1616
foreign import lib "windows/lua52dll.lib"
17-
} else when ODIN_OS == .Linux {
17+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
1818
foreign import lib "linux/liblua52.so"
1919
} else {
2020
foreign import lib "system:lua5.2"
2121
}
2222
} else {
2323
when ODIN_OS == .Windows {
2424
foreign import lib "windows/lua52dll.lib"
25-
} else when ODIN_OS == .Linux {
25+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
2626
foreign import lib "linux/liblua52.a"
2727
} else {
2828
foreign import lib "system:lua5.2"

vendor/lua/5.3/lua.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ when LUA_SHARED {
1414
when ODIN_OS == .Windows {
1515
// Does nothing special on windows
1616
foreign import lib "windows/lua53dll.lib"
17-
} else when ODIN_OS == .Linux {
17+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
1818
foreign import lib "linux/liblua53.so"
1919
} else {
2020
foreign import lib "system:lua5.3"
2121
}
2222
} else {
2323
when ODIN_OS == .Windows {
2424
foreign import lib "windows/lua53dll.lib"
25-
} else when ODIN_OS == .Linux {
25+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
2626
foreign import lib "linux/liblua53.a"
2727
} else {
2828
foreign import lib "system:lua5.3"

vendor/lua/5.4/lua.odin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ when LUA_SHARED {
1414
when ODIN_OS == .Windows {
1515
// LUA_SHARED does nothing special on windows
1616
foreign import lib "windows/lua54dll.lib"
17-
} else when ODIN_OS == .Linux {
17+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
1818
foreign import lib "linux/liblua54.so"
1919
} else {
2020
foreign import lib "system:lua5.4"
2121
}
2222
} else {
2323
when ODIN_OS == .Windows {
2424
foreign import lib "windows/lua54dll.lib"
25-
} else when ODIN_OS == .Linux {
25+
} else when ODIN_OS == .Linux && ODIN_ARCH == .amd64 {
2626
foreign import lib "linux/liblua54.a"
2727
} else {
2828
foreign import lib "system:lua5.4"

0 commit comments

Comments
 (0)