Try to link LargeFiles probes
C allows calls to undeclared functions, so the LargeFiles probes must
check whether the test program can be linked successfully.
Fixes macOS build.
diff --git a/src/Charmonizer/Probe/LargeFiles.c b/src/Charmonizer/Probe/LargeFiles.c
index 5179bb3..57acd1b 100644
--- a/src/Charmonizer/Probe/LargeFiles.c
+++ b/src/Charmonizer/Probe/LargeFiles.c
@@ -154,10 +154,11 @@
CHAZ_QUOTE( %s )
CHAZ_QUOTE( #include <stdio.h> )
CHAZ_QUOTE( int a[sizeof(%s)==8?1:-1]; )
- CHAZ_QUOTE( void f() { )
+ CHAZ_QUOTE( int main() { )
CHAZ_QUOTE( FILE *f = %s("_charm_stdio64", "w"); )
CHAZ_QUOTE( %s pos = %s(f); )
CHAZ_QUOTE( %s(f, 0, SEEK_SET); )
+ CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( } );
char code_buf[sizeof(stdio64_code) + 200];
@@ -168,7 +169,7 @@
combo->fseek_command);
/* Verify compilation and that the offset type has 8 bytes. */
- return chaz_CC_test_compile(code_buf);
+ return chaz_CC_test_link(code_buf);
}
static void
@@ -200,12 +201,15 @@
chaz_LargeFiles_probe_lseek(chaz_LargeFiles_unbuff_combo *combo) {
static const char lseek_code[] =
CHAZ_QUOTE( %s )
- CHAZ_QUOTE( void f() { %s(0, 0, SEEK_SET); } );
+ CHAZ_QUOTE( int main() { )
+ CHAZ_QUOTE( %s(0, 0, SEEK_SET); )
+ CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( } );
char code_buf[sizeof(lseek_code) + 100];
/* Verify compilation. */
sprintf(code_buf, lseek_code, combo->includes, combo->lseek_command);
- return chaz_CC_test_compile(code_buf);
+ return chaz_CC_test_link(code_buf);
}
static int
@@ -214,15 +218,16 @@
* fine as long as it compiles. */
static const char pread64_code[] =
CHAZ_QUOTE( %s )
- CHAZ_QUOTE( void f() { )
+ CHAZ_QUOTE( int main() { )
CHAZ_QUOTE( char buf[1]; )
CHAZ_QUOTE( %s(0, buf, 1, 1); )
+ CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( } );
char code_buf[sizeof(pread64_code) + 100];
/* Verify compilation. */
sprintf(code_buf, pread64_code, combo->includes, combo->pread64_command);
- return chaz_CC_test_compile(code_buf);
+ return chaz_CC_test_link(code_buf);
}
static void