Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static on macosx #4332

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Static on macosx #4332

wants to merge 3 commits into from

Conversation

Smilex
Copy link

@Smilex Smilex commented Oct 1, 2024

I have tested that this works with the iPhone simulator

Basically just call "libtool -static" on the object files

An unfortunate thing I have to do when linking to a static odin library, is to call runtime._startup_runtime()

Copy link
Collaborator

@laytan laytan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I see the .dSYM is not created for a -debug -build-mode:static, it should be possible right?
  • It must be possible to set an entry/init section in the static library so the runtime._startup_runtime() and similar things can be called

link_command_line = gb_string_appendc(link_command_line, " -Wno-unused-command-line-argument ");
link_command_line = gb_string_append_fmt(link_command_line, " -o \"%.*s\" ", LIT(output_filename));

link_command_line = gb_string_appendc(link_command_line, object_files);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you move the object files from before the -o to after it?

@@ -631,7 +627,7 @@ gb_internal i32 linker_stage(LinkerData *gen) {
link_settings = gb_string_append_fmt(link_settings, "-mmacosx-version-min=%.*s ", LIT(build_context.minimum_os_version_string));
}

if (build_context.build_mode != BuildMode_DynamicLibrary) {
if (build_context.build_mode != BuildMode_DynamicLibrary && build_context.build_mode != BuildMode_StaticLibrary) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look needed? link_settings isn't used when you do a static library from what I can tell.

static_link_command_line = gb_string_appendc(static_link_command_line, object_files);
return system_exec_command_line_app("libtool", static_link_command_line);
} else {
compiler_error("-build-mode:static on Linux and similar targets");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
compiler_error("-build-mode:static on Linux and similar targets");
compiler_error("TODO: -build-mode:static on this target");

@Smilex
Copy link
Author

Smilex commented Oct 2, 2024

  • I see the .dSYM is not created for a -debug -build-mode:static, it should be possible right?
  • It must be possible to set an entry/init section in the static library so the runtime._startup_runtime() and similar things can be called

Looks like I need to call "dsymutil <your_program>" somehow, but it says that the object files don't have debug data. I'll look into it later

However I have no problem debugging in my example code, so maybe it isn't a thing for static libraries?

@laytan laytan marked this pull request as draft October 28, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants