-
Notifications
You must be signed in to change notification settings - Fork 169
Support immediate binding option #335
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -117,7 +117,17 @@ int main(int argc, char *argv[]) | |||||||||||||||||||||||||||||||||||||||||||||||
| libc = false; | ||||||||||||||||||||||||||||||||||||||||||||||||
| else if (!strcmp(argv[i], "--dynlink")) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dynlink = true; | ||||||||||||||||||||||||||||||||||||||||||||||||
| else if (!strcmp(argv[i], "-E")) | ||||||||||||||||||||||||||||||||||||||||||||||||
| else if (!strcmp(argv[i], "-z")) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (i + 1 >= argc) | ||||||||||||||||||||||||||||||||||||||||||||||||
| usage_error("-z requires \"lazy\" or \"now\""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (!strcmp(argv[i + 1], "lazy")) | ||||||||||||||||||||||||||||||||||||||||||||||||
| imm_binding = false; | ||||||||||||||||||||||||||||||||||||||||||||||||
| else if (!strcmp(argv[i + 1], "now")) | ||||||||||||||||||||||||||||||||||||||||||||||||
| imm_binding = true; | ||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||
| usage_error("-z requires \"lazy\" or \"now\""); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (!strcmp(argv[i], "-E")) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+120
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The Prompt for AI agents
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| expand_only = true; | ||||||||||||||||||||||||||||||||||||||||||||||||
| else if (!strcmp(argv[i], "-o")) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (i + 1 < argc) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -131,10 +141,21 @@ int main(int argc, char *argv[]) | |||||||||||||||||||||||||||||||||||||||||||||||
| in = argv[i]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynlink) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| switch (ELF_MACHINE) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* The following 64-bit targets have no lazy-resolution path, so | ||||||||||||||||||||||||||||||||||||||||||||||||
| * immediate binding must be used. | ||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| case ELF_MACHINE_X86_64: | ||||||||||||||||||||||||||||||||||||||||||||||||
| case ELF_MACHINE_AARCH64: | ||||||||||||||||||||||||||||||||||||||||||||||||
| imm_binding = true; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (!in) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| printf( | ||||||||||||||||||||||||||||||||||||||||||||||||
| "Usage: shecc [-o output] [+m] [--dot] [--dump-ir] [--no-libc] " | ||||||||||||||||||||||||||||||||||||||||||||||||
| "[--dynlink] [-E] <input.c>\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| "[--dynlink] [-z <lazy | now>] [-E] <input.c>\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| usage_error("Missing source file"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: When a
BINDING=nowbuild runsmake check, the test suite still exercises lazy binding. Thecheck-stage0/check-stage2/check-abi-*targets forward only$(DYNLINK)to the test drivers, andtests/driver.shcompiles its test programs with a plain--dynlink(no-z now), so on arm/riscv those programs default to lazy binding. With this changeBINDINGbecomes a build knob that stage1/stage2 honor, but the tests built bymake checknever verify the immediate-binding path this PR adds. Forward$(BINDING)(or a corresponding-zflag) to the driver invocations so immediate binding can actually be validated, matching the PR's TODO about CI validation.Prompt for AI agents