mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Merge pull request #775 from Tetralux/fix-type-table-unix
Fix -build-mode:shared type table on Unix
This commit is contained in:
+38
-30
@@ -382,30 +382,24 @@ i32 linker_stage(lbGenerator *gen) {
|
|||||||
// Unlike the Win32 linker code, the output_ext includes the dot, because
|
// Unlike the Win32 linker code, the output_ext includes the dot, because
|
||||||
// typically executable files on *NIX systems don't have extensions.
|
// typically executable files on *NIX systems don't have extensions.
|
||||||
String output_ext = {};
|
String output_ext = {};
|
||||||
char const *link_settings = "";
|
gbString link_settings = gb_string_make_reserve(heap_allocator(), 32);
|
||||||
char const *linker;
|
char const *linker;
|
||||||
if (build_context.build_mode == BuildMode_DynamicLibrary) {
|
if (build_context.build_mode == BuildMode_DynamicLibrary) {
|
||||||
|
// NOTE(tetra, 2020-11-06): __$startup_runtime must be called at DLL load time.
|
||||||
|
// Clang, for some reason, won't let us pass the '-init' flag that lets us do this,
|
||||||
|
// so use ld instead.
|
||||||
|
// :UseLDForShared
|
||||||
|
linker = "ld";
|
||||||
|
link_settings = gb_string_appendc(link_settings, "-init '__$startup_runtime' ");
|
||||||
// Shared libraries are .dylib on MacOS and .so on Linux.
|
// Shared libraries are .dylib on MacOS and .so on Linux.
|
||||||
#if defined(GB_SYSTEM_OSX)
|
#if defined(GB_SYSTEM_OSX)
|
||||||
output_ext = STR_LIT(".dylib");
|
output_ext = STR_LIT(".dylib");
|
||||||
link_settings = "-dylib -dynamic";
|
link_settings = gb_string_appendc(link_settings, "-dylib -dynamic ");
|
||||||
#else
|
#else
|
||||||
output_ext = STR_LIT(".so");
|
output_ext = STR_LIT(".so");
|
||||||
link_settings = "-shared";
|
link_settings = gb_string_appendc(link_settings, "-shared ");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// TODO: Do I need anything here?
|
|
||||||
link_settings = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (build_context.out_filepath.len > 0) {
|
|
||||||
//NOTE(thebirk): We have a custom -out arguments, so we should use the extension from that
|
|
||||||
isize pos = string_extension_position(build_context.out_filepath);
|
|
||||||
if (pos > 0) {
|
|
||||||
output_ext = substring(build_context.out_filepath, pos, build_context.out_filepath.len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(GB_SYSTEM_OSX)
|
#if defined(GB_SYSTEM_OSX)
|
||||||
linker = "ld";
|
linker = "ld";
|
||||||
#else
|
#else
|
||||||
@@ -415,6 +409,15 @@ i32 linker_stage(lbGenerator *gen) {
|
|||||||
// Clang can figure out linker flags for us, and that's good enough _for now_.
|
// Clang can figure out linker flags for us, and that's good enough _for now_.
|
||||||
linker = "clang -Wno-unused-command-line-argument";
|
linker = "clang -Wno-unused-command-line-argument";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (build_context.out_filepath.len > 0) {
|
||||||
|
//NOTE(thebirk): We have a custom -out arguments, so we should use the extension from that
|
||||||
|
isize pos = string_extension_position(build_context.out_filepath);
|
||||||
|
if (pos > 0) {
|
||||||
|
output_ext = substring(build_context.out_filepath, pos, build_context.out_filepath.len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exit_code = system_exec_command_line_app("ld-link",
|
exit_code = system_exec_command_line_app("ld-link",
|
||||||
"%s %s -o \"%.*s%.*s\" %s "
|
"%s %s -o \"%.*s%.*s\" %s "
|
||||||
@@ -2171,30 +2174,24 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
// Unlike the Win32 linker code, the output_ext includes the dot, because
|
// Unlike the Win32 linker code, the output_ext includes the dot, because
|
||||||
// typically executable files on *NIX systems don't have extensions.
|
// typically executable files on *NIX systems don't have extensions.
|
||||||
String output_ext = {};
|
String output_ext = {};
|
||||||
char const *link_settings = "";
|
gbString link_settings = gb_string_make_reserve(heap_allocator(), 32);
|
||||||
char const *linker;
|
char const *linker;
|
||||||
if (build_context.build_mode == BuildMode_DynamicLibrary) {
|
if (build_context.build_mode == BuildMode_DynamicLibrary) {
|
||||||
|
// NOTE(tetra, 2020-11-06): __$startup_runtime must be called at DLL load time.
|
||||||
|
// Clang, for some reason, won't let us pass the '-init' flag that lets us do this,
|
||||||
|
// so use ld instead.
|
||||||
|
// :UseLDForShared
|
||||||
|
linker = "ld";
|
||||||
|
link_settings = gb_string_appendc(link_settings, "-init '__$startup_runtime' ");
|
||||||
// Shared libraries are .dylib on MacOS and .so on Linux.
|
// Shared libraries are .dylib on MacOS and .so on Linux.
|
||||||
#if defined(GB_SYSTEM_OSX)
|
#if defined(GB_SYSTEM_OSX)
|
||||||
output_ext = STR_LIT(".dylib");
|
output_ext = STR_LIT(".dylib");
|
||||||
link_settings = "-dylib -dynamic";
|
link_settings = gb_string_appendc(link_settings, "-dylib -dynamic ");
|
||||||
#else
|
#else
|
||||||
output_ext = STR_LIT(".so");
|
output_ext = STR_LIT(".so");
|
||||||
link_settings = "-shared";
|
link_settings = gb_string_appendc(link_settings, "-shared ");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// TODO: Do I need anything here?
|
|
||||||
link_settings = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (build_context.out_filepath.len > 0) {
|
|
||||||
//NOTE(thebirk): We have a custom -out arguments, so we should use the extension from that
|
|
||||||
isize pos = string_extension_position(build_context.out_filepath);
|
|
||||||
if (pos > 0) {
|
|
||||||
output_ext = substring(build_context.out_filepath, pos, build_context.out_filepath.len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(GB_SYSTEM_OSX)
|
#if defined(GB_SYSTEM_OSX)
|
||||||
linker = "ld";
|
linker = "ld";
|
||||||
#else
|
#else
|
||||||
@@ -2204,6 +2201,17 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
// Clang can figure out linker flags for us, and that's good enough _for now_.
|
// Clang can figure out linker flags for us, and that's good enough _for now_.
|
||||||
linker = "clang -Wno-unused-command-line-argument";
|
linker = "clang -Wno-unused-command-line-argument";
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (build_context.out_filepath.len > 0) {
|
||||||
|
//NOTE(thebirk): We have a custom -out arguments, so we should use the extension from that
|
||||||
|
isize pos = string_extension_position(build_context.out_filepath);
|
||||||
|
if (pos > 0) {
|
||||||
|
output_ext = substring(build_context.out_filepath, pos, build_context.out_filepath.len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
exit_code = system_exec_command_line_app("ld-link",
|
exit_code = system_exec_command_line_app("ld-link",
|
||||||
"%s \"%.*s.o\" -o \"%.*s%.*s\" %s "
|
"%s \"%.*s.o\" -o \"%.*s%.*s\" %s "
|
||||||
|
|||||||
Reference in New Issue
Block a user