diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 78af3f8a4..ee25cb495 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -12582,8 +12582,11 @@ END IF 'Clear nm output from previous runs FOR x = 1 TO ResolveStaticFunctions IF LEN(ResolveStaticFunction_File(x)) THEN - s$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x)) - IF _FILEEXISTS(s$) THEN KILL s$ + s$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 0) + IF _FILEEXISTS(s$) THEN KILL s$: ClearBuffers s$ + + s$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 1) + IF _FILEEXISTS(s$) THEN KILL s$: ClearBuffers s$ END IF NEXT x @@ -12602,7 +12605,8 @@ IF os$ = "WIN" THEN 'resolve static function definitions and add to global.txt FOR x = 1 TO ResolveStaticFunctions - nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x)) + nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 0) + nm_output_file_dynamic$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 1) IF LEN(ResolveStaticFunction_File(x)) THEN n = 0 @@ -12659,8 +12663,8 @@ IF os$ = "WIN" THEN END IF IF n = 0 THEN 'a C++ dynamic object library? - IF NOT _FILEEXISTS(nm_output_file$) THEN - SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file$) + IF NOT _FILEEXISTS(nm_output_file_dynamic$) THEN + SHELL _HIDE "cmd /c internal\c\c_compiler\bin\nm.exe " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file_dynamic$) END IF s$ = " " + ResolveStaticFunction_Name(x) + "(" fh = OpenBuffer%("I", nm_output_file$) @@ -12687,7 +12691,7 @@ IF os$ = "WIN" THEN IF n = 0 THEN 'a C dynamic object library? s$ = " " + ResolveStaticFunction_Name(x) - fh = OpenBuffer%("I", nm_output_file$) + fh = OpenBuffer%("I", nm_output_file_dynamic$) DO UNTIL EndOfBuf%(fh) a$ = ReadBufLine$(fh) IF LEN(a$) THEN @@ -12751,7 +12755,8 @@ IF os$ = "LNX" THEN END IF FOR x = 1 TO ResolveStaticFunctions - nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x)) + nm_output_file$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 0) + nm_output_file_dynamic$ = MakeNMOutputFilename$(ResolveStaticFunction_File(x), 1) IF LEN(ResolveStaticFunction_File(x)) THEN n = 0 @@ -12814,8 +12819,8 @@ IF os$ = "LNX" THEN IF n = 0 THEN 'a C++ dynamic object library? IF MacOSX THEN GOTO macosx_libfind_failed - IF NOT _FILEEXISTS(nm_output_file$) THEN - SHELL _HIDE "nm " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file$) + " 2>" + AddQuotes$(tmpdir$ + "nm_error.txt") + IF NOT _FILEEXISTS(nm_output_file_dynamic$) THEN + SHELL _HIDE "nm " + AddQuotes$(ResolveStaticFunction_File(x)) + " -D --demangle -g >" + AddQuotes$(nm_output_file_dynamic$) + " 2>" + AddQuotes$(tmpdir$ + "nm_error.txt") END IF s$ = " " + ResolveStaticFunction_Name(x) + "(" fh = OpenBuffer%("I", nm_output_file$) @@ -12842,7 +12847,7 @@ IF os$ = "LNX" THEN IF n = 0 THEN 'a C dynamic object library? s$ = " " + ResolveStaticFunction_Name(x) - fh = OpenBuffer%("I", nm_output_file$) + fh = OpenBuffer%("I", nm_output_file_dynamic$) DO UNTIL EndOfBuf%(fh) a$ = ReadBufLine$(fh) IF LEN(a$) THEN diff --git a/source/utilities/build.bas b/source/utilities/build.bas index b03838c3b..9ef5f17ff 100644 --- a/source/utilities/build.bas +++ b/source/utilities/build.bas @@ -27,6 +27,8 @@ FUNCTION GetMakeExecutable$ () END IF END FUNCTION -FUNCTION MakeNMOutputFilename$ (libfile AS STRING) - MakeNMOutputFilename$ = tmpdir$ + "nm_output_" + StrReplace$(StrReplace$(libfile, pathsep$, "."), ":", ".") + ".txt" +FUNCTION MakeNMOutputFilename$ (libfile AS STRING, dynamic As Long) + If dynamic Then dyn$ = "_dynamic" Else dyn$ = "" + + MakeNMOutputFilename$ = tmpdir$ + "nm_output_" + StrReplace$(StrReplace$(libfile, pathsep$, "."), ":", ".") + dyn$ + ".txt" END FUNCTION diff --git a/tests/compile_tests/declare_library_external/liblibstripped.so b/tests/compile_tests/declare_library_external/liblibstripped.so new file mode 100644 index 000000000..831ff9ab4 Binary files /dev/null and b/tests/compile_tests/declare_library_external/liblibstripped.so differ diff --git a/tests/compile_tests/declare_library_external/test_stripped.bas b/tests/compile_tests/declare_library_external/test_stripped.bas new file mode 100644 index 000000000..b6264036a --- /dev/null +++ b/tests/compile_tests/declare_library_external/test_stripped.bas @@ -0,0 +1,23 @@ +$CONSOLE:ONLY + +$IF LNX THEN + +' This file is missing the regular symbol table and only contains the dynamic symbol table +DECLARE LIBRARY "./libstripped" + FUNCTION add_values&(BYVAL v1 AS LONG, BYVAL v2 as LONG) +END DECLARE + +result = add_values&(2, 3) +PRINT result + + +$ELSE + +' Windows can't use regular DECLARE LIBRARY to link against a dll, just skip this test +' +' Mac OS dylib files don't have a dynamic symbol table, so also nothing to test +PRINT 5 + +$END IF + +SYSTEM diff --git a/tests/compile_tests/declare_library_external/test_stripped.output b/tests/compile_tests/declare_library_external/test_stripped.output new file mode 100644 index 000000000..922e8a64c --- /dev/null +++ b/tests/compile_tests/declare_library_external/test_stripped.output @@ -0,0 +1 @@ + 5