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

Only pass --global-base to the linker if its set to a non-default value #18056

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 13, 2022

Otherwise rely on the linker default value of 1024.

This change is in preparation of using --stack-first in debug builds. When --stack-first is passed to the linker --global-base is ignored (it should really be an error do this).

I also avoid needless passing redundant arguments to the linker.

@sbc100 sbc100 requested a review from kripken October 13, 2022 19:53
Otherwise rely on the linker default value of 1024.

This change is in preparation of using `--stack-first` in debug builds.
When `--stack-first` is passed to the linker `--global-base` is ignored
(it should really be an error do this).

I also avoid needless passing redundant arguments to the linker.
@sbc100 sbc100 force-pushed the default_global_base branch from 485de9c to 15255eb Compare October 13, 2022 19:54
@@ -225,7 +225,7 @@ def lld_flags_for_executable(external_symbols):
cmd.append('--max-memory=%d' % settings.INITIAL_MEMORY)
elif settings.MAXIMUM_MEMORY != -1:
cmd.append('--max-memory=%d' % settings.MAXIMUM_MEMORY)
if not settings.RELOCATABLE:
if settings.GLOBAL_BASE != 1024 and not settings.RELOCATABLE:
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth baking in current defaults of wasm-ld here? I worry about them changing. It seems safer to me to keep passing this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are probably right there.

I guess part of my intention here is to express that case when the user doesn't care about the global base at all.. which is the normal case.

On the other hand, since you described the low memory optimization that binaryen does I think emscripten does actually care in more cases than I had thought.

I guess what I want here is to say "If the user specified a specific global base, or if emscripten want to run the low memory optimization, then pass an explictic stack base... otherwise we don't care and wasm-ld can choose whatever it wants"

Copy link
Member

Choose a reason for hiding this comment

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

I see. Yeah, that makes sense. How about having a place that decides whether we use the low-memory optimization, and it sets GLOBAL_BASE if so? (to 1024) And if not it would be null. Then we could avoid passing null to wasm-ld.

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