Skip to content

Commit bddd1d9

Browse files
Ailin Nemuidcbaker
authored andcommitted
tests: Test extern'd globals on MacOS with the Apple Archiver
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]>
1 parent 589e298 commit bddd1d9

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
2+
3+
#include <stdio.h>
4+
5+
extern int l2;
6+
void l1(void)
7+
{
8+
printf("l1 %d\n", l2);
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
2+
3+
int l2;
4+
void l2_func(void)
5+
{
6+
l2 = 77;
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
2+
3+
project('global variable test', 'c')
4+
5+
lib = static_library('mylib', 'libfile.c', 'libfile2.c')
6+
test('global variable', executable('prog', 'prog.c', link_with: lib))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[binaries]
2+
ar = 'ar'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Source: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
2+
3+
extern void l1(void);
4+
int main(void)
5+
{
6+
l1();
7+
}

0 commit comments

Comments
 (0)