Skip to content

Commit

Permalink
tests: Test extern'd globals on MacOS with the Apple Archiver
Browse files Browse the repository at this point in the history
This forces the use of the Apple archiver, since that archiver doesn't
add extern'd variables to the symbol table automatically, and instead
requires that ranlib be used. A native file is used to ensure that
Apple's ar is used even in the presence of llvm or gcc in the path with
their superior archivers.

Co-authored-by: Dylan Baker <[email protected]>
  • Loading branch information
2 people authored and xclaesse committed Sep 4, 2023
1 parent 855f9a6 commit 55eaba9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test cases/osx/9 global variable ar/libfile.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html

#include <stdio.h>

extern int l2;
void l1(void)
{
printf("l1 %d\n", l2);
}
7 changes: 7 additions & 0 deletions test cases/osx/9 global variable ar/libfile2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html

int l2;
void l2_func(void)
{
l2 = 77;
}
6 changes: 6 additions & 0 deletions test cases/osx/9 global variable ar/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html

project('global variable test', 'c')

lib = static_library('mylib', 'libfile.c', 'libfile2.c')
test('global variable', executable('prog', 'prog.c', link_with: lib))
2 changes: 2 additions & 0 deletions test cases/osx/9 global variable ar/nativefile.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[binaries]
ar = 'ar'
7 changes: 7 additions & 0 deletions test cases/osx/9 global variable ar/prog.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html

extern void l1(void);
int main(void)
{
l1();
}

0 comments on commit 55eaba9

Please sign in to comment.