Skip to content

Conversation

Luukdegram
Copy link
Contributor

Regardless of the build mode (build-exe, build-lib), always set the default stack size to 1MB. Previously, this was only done when using build-exe, making the inconsistancy confusing. The user can still override this behavior by providing the --stack <size> flag.

Closes #3735.

Regardless of the build mode (build-exe, build-lib), always
set the default stack size to 1MB. Previously, this was only
done when using build-exe, making the inconsistancy confusing.
The user can still override this behavior by providing the
`--stack <size>` flag.
const arg = try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size});
try argv.append(arg);
}
} else if (self.base.options.entry == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this is correct here? The previous version of the code did not check for entry at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but a little bit above we set the entry if the user provided it. It's invalid to pass both an entry point and --no-entry. I figured I'd get that fix in while at it.

Copy link
Member

Choose a reason for hiding this comment

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

If it's invalid, should we perhaps flag it up as an error to the user?

Copy link
Contributor Author

@Luukdegram Luukdegram Aug 24, 2022

Choose a reason for hiding this comment

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

I don't think so. --entry is given by the user, whereas --no-entry is a flag we set by default depending on the output mode. So the user never creates this invalid state, it's the Zig toolchain that should ensure it doesn't occur. Unless we disallow have an entry point in non build-exe modes, but given how Wasm runs in runtimes I think it's perfectly valid to have an environment where you do have a custom entry, but not the _start logic.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, so we don't expose --no-entry to the user? I'm curious though, what is the behavior of LLD upon receiving both flags in a single linker line, do you know perhaps?

Copy link
Contributor Author

@Luukdegram Luukdegram Aug 24, 2022

Choose a reason for hiding this comment

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

LLD will ignore the --entry flag in such case, which may confuse the user, as they may be unaware that --no-entry was passed to lld also and therefore have their own flag ignored.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for double checking! I am fine with the current approach. In the future though, I wonder if we should perhaps make it a hard error. Food for thought!

@andrewrk andrewrk merged commit fffece1 into ziglang:master Aug 29, 2022
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.

wasm has a max stack size of ~66K

3 participants