-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
update @export to handle linksection #2679
Comments
Oh, actually this compile error should go away:
I'm still in favor of this proposal (maybe we make an error for if the sections disagree) but in the meantime the compile error for section names on extern variables can go away. |
previously `@export` for an array would panic with a TODO message. now it will do the export. However, it uses the variable's name rather than the name passed to `@export`. Issue #2679 remains open for that problem.
Previously, the symbol name parameter of `@export` would be ignored for variables, and the variable name would be used for the symbol name. Now it works as expected. See #2679
I fixed the issue with // This is to remove the SHF_ALLOC flag from the .gdb_debug_scripts section so that it does not get garbage collected by the linker.
comptime {
asm (
\\.pushsection ".debug_gdb_scripts", "MS",@progbits,1
\\.popsection
);
}
fn Generic(comptime T: type) type {
return struct {
const python_code = @typeName(@This()) ++
\\ your generic python
\\ code goes here
;
// note that you have to make this an extern for now
extern const script linksection(".debug_gdb_scripts") = "\x04gdb.inlined-script\n" ++ python_code ++ [1]u8{0};
comptime {
if (builtin.mode == .Debug) {
@export("gdb_script" ++ @typeName(@This()), script, .Strong);
}
}
};
}
comptime {
_ = Generic(i32);
_ = Generic(f64);
} Relevant LLVM output: @"gdb_scriptGeneric(i32)" = dso_local unnamed_addr constant [69 x i8] c"\04gdb.inlined-script\0AGeneric(i32) your generic python\0A code goes here\00", section ".debug_gdb_scripts", align 1
@"gdb_scriptGeneric(f64)" = dso_local unnamed_addr constant [69 x i8] c"\04gdb.inlined-script\0AGeneric(f64) your generic python\0A code goes here\00", section ".debug_gdb_scripts", align 1 This will unblock #2681, which should not wait on this issue to be solved, because it will remain open until |
Use a struct as second parameter to be future proof (and also allows to specify default values for the parameters) Closes ziglang#2679 as it was just a matter of a few lines of code.
Use a struct as second parameter to be future proof (and also allows to specify default values for the parameters) Closes ziglang#2679 as it was just a matter of a few lines of code.
Use a struct as second parameter to be future proof (and also allows to specify default values for the parameters) Closes #2679 as it was just a matter of a few lines of code.
Use case: putting .gdb_script entries in generic types. See also #25.
Here's code that I tried:
I needed to make a small improvement to
@export
to support arrays:And then the above example gives me:
This compile error makes sense and should stay. The link section should be a parameter to
@export
. But we do want the concept of default link sections. We also want strong linkage to be the default. I propose that the definition of@export
is changed to this:Where
ExportOptions
is defined in@import("builtin")
like this:The text was updated successfully, but these errors were encountered: