mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Merge pull request #768 from Platin21/fix_macos_linking
Fix macOS linking for user/local/libs and object files
This commit is contained in:
+24
-23
@@ -341,12 +341,12 @@ i32 linker_stage(lbGenerator *gen) {
|
|||||||
String lib_name = lib;
|
String lib_name = lib;
|
||||||
lib_name = remove_extension_from_path(lib_name);
|
lib_name = remove_extension_from_path(lib_name);
|
||||||
lib_str = gb_string_append_fmt(lib_str, " -framework %.*s ", LIT(lib_name));
|
lib_str = gb_string_append_fmt(lib_str, " -framework %.*s ", LIT(lib_name));
|
||||||
} else if (string_ends_with(lib, str_lit(".a"))) {
|
} else if (string_ends_with(lib, str_lit(".a")) || string_ends_with(lib, str_lit(".o")) || string_ends_with(lib, str_lit(".dylib"))) {
|
||||||
|
// For:
|
||||||
|
// object
|
||||||
|
// dynamic lib
|
||||||
// static libs, absolute full path relative to the file in which the lib was imported from
|
// static libs, absolute full path relative to the file in which the lib was imported from
|
||||||
lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
|
lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
|
||||||
} else if (string_ends_with(lib, str_lit(".dylib"))) {
|
|
||||||
// dynamic lib
|
|
||||||
lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
|
|
||||||
} else {
|
} else {
|
||||||
// dynamic or static system lib, just link regularly searching system library paths
|
// dynamic or static system lib, just link regularly searching system library paths
|
||||||
lib_str = gb_string_append_fmt(lib_str, " -l%.*s ", LIT(lib));
|
lib_str = gb_string_append_fmt(lib_str, " -l%.*s ", LIT(lib));
|
||||||
@@ -431,19 +431,19 @@ i32 linker_stage(lbGenerator *gen) {
|
|||||||
" -e _main "
|
" -e _main "
|
||||||
#endif
|
#endif
|
||||||
, linker, object_files, LIT(output_base), LIT(output_ext),
|
, linker, object_files, LIT(output_base), LIT(output_ext),
|
||||||
lib_str,
|
#if defined(GB_SYSTEM_OSX)
|
||||||
#if defined(GB_SYSTEM_OSX)
|
"-lSystem -lm -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib",
|
||||||
"-lSystem -lm -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
|
#else
|
||||||
#else
|
"-lc -lm",
|
||||||
"-lc -lm",
|
#endif
|
||||||
#endif
|
lib_str,
|
||||||
LIT(build_context.link_flags),
|
LIT(build_context.link_flags),
|
||||||
LIT(build_context.extra_linker_flags),
|
LIT(build_context.extra_linker_flags),
|
||||||
link_settings);
|
link_settings);
|
||||||
if (exit_code != 0) {
|
if (exit_code != 0) {
|
||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GB_SYSTEM_OSX)
|
#if defined(GB_SYSTEM_OSX)
|
||||||
if (build_context.ODIN_DEBUG) {
|
if (build_context.ODIN_DEBUG) {
|
||||||
// NOTE: macOS links DWARF symbols dynamically. Dsymutil will map the stubs in the exe
|
// NOTE: macOS links DWARF symbols dynamically. Dsymutil will map the stubs in the exe
|
||||||
@@ -2136,13 +2136,14 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
String lib_name = lib;
|
String lib_name = lib;
|
||||||
lib_name = remove_extension_from_path(lib_name);
|
lib_name = remove_extension_from_path(lib_name);
|
||||||
lib_str = gb_string_append_fmt(lib_str, " -framework %.*s ", LIT(lib_name));
|
lib_str = gb_string_append_fmt(lib_str, " -framework %.*s ", LIT(lib_name));
|
||||||
} else if (string_ends_with(lib, str_lit(".a"))) {
|
|
||||||
// static libs, absolute full path relative to the file in which the lib was imported from
|
} else if (string_ends_with(lib, str_lit(".a")) || string_ends_with(lib, str_lit(".o")) || string_ends_with(lib, str_lit(".dylib"))) {
|
||||||
lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
|
// For:
|
||||||
} else if (string_ends_with(lib, str_lit(".dylib"))) {
|
// object
|
||||||
// dynamic lib
|
// dynamic lib
|
||||||
lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
|
// static libs, absolute full path relative to the file in which the lib was imported from
|
||||||
} else {
|
lib_str = gb_string_append_fmt(lib_str, " %.*s ", LIT(lib));
|
||||||
|
} else {
|
||||||
// dynamic or static system lib, just link regularly searching system library paths
|
// dynamic or static system lib, just link regularly searching system library paths
|
||||||
lib_str = gb_string_append_fmt(lib_str, " -l%.*s ", LIT(lib));
|
lib_str = gb_string_append_fmt(lib_str, " -l%.*s ", LIT(lib));
|
||||||
}
|
}
|
||||||
@@ -2220,11 +2221,11 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
#endif
|
#endif
|
||||||
, linker, LIT(output_base), LIT(output_base), LIT(output_ext),
|
, linker, LIT(output_base), LIT(output_base), LIT(output_ext),
|
||||||
lib_str,
|
lib_str,
|
||||||
#if defined(GB_SYSTEM_OSX)
|
#if defined(GB_SYSTEM_OSX)
|
||||||
"-lSystem -lm -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
|
"-lSystem -lm -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/usr/local/lib",
|
||||||
#else
|
#else
|
||||||
"-lc -lm",
|
"-lc -lm",
|
||||||
#endif
|
#endif
|
||||||
LIT(build_context.link_flags),
|
LIT(build_context.link_flags),
|
||||||
LIT(build_context.extra_linker_flags),
|
LIT(build_context.extra_linker_flags),
|
||||||
link_settings);
|
link_settings);
|
||||||
|
|||||||
Reference in New Issue
Block a user