valgrind client requests for undefined values
with this change, when you assign undefined, zig emits a few
assembly instructions to tell valgrind that the memory is undefined
it's on by default for debug builds, and disabled otherwise. only
support for linux, darwin, solaris, mingw on x86_64 is currently
implemented.
--disable-valgrind turns it off even in debug mode.
--enable-valgrind turns it on even in release modes.
It's always disabled for compiler_rt.a and builtin.a.
Adds `@import("builtin").valgrind_support` which lets code know
at comptime whether valgrind client requests are enabled.
See #1989
This commit is contained in:
@@ -544,7 +544,7 @@ void get_target_triple(Buf *triple, const ZigTarget *target) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_os_darwin(ZigTarget *target) {
|
||||
bool target_is_darwin(const ZigTarget *target) {
|
||||
switch (target->os) {
|
||||
case OsMacOSX:
|
||||
case OsIOS:
|
||||
@@ -566,7 +566,7 @@ void resolve_target_object_format(ZigTarget *target) {
|
||||
case ZigLLVM_thumb:
|
||||
case ZigLLVM_x86:
|
||||
case ZigLLVM_x86_64:
|
||||
if (is_os_darwin(target)) {
|
||||
if (target_is_darwin(target)) {
|
||||
target->oformat = ZigLLVM_MachO;
|
||||
} else if (target->os == OsWindows) {
|
||||
target->oformat = ZigLLVM_COFF;
|
||||
@@ -626,7 +626,7 @@ void resolve_target_object_format(ZigTarget *target) {
|
||||
|
||||
case ZigLLVM_ppc:
|
||||
case ZigLLVM_ppc64:
|
||||
if (is_os_darwin(target)) {
|
||||
if (target_is_darwin(target)) {
|
||||
target->oformat = ZigLLVM_MachO;
|
||||
} else {
|
||||
target->oformat= ZigLLVM_ELF;
|
||||
@@ -1084,3 +1084,17 @@ bool target_is_arm(const ZigTarget *target) {
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
// Valgrind supports more, but Zig does not support them yet.
|
||||
bool target_has_valgrind_support(const ZigTarget *target) {
|
||||
switch (target->arch.arch) {
|
||||
case ZigLLVM_UnknownArch:
|
||||
zig_unreachable();
|
||||
case ZigLLVM_x86_64:
|
||||
return (target->os == OsLinux || target_is_darwin(target) || target->os == OsSolaris ||
|
||||
(target->os == OsWindows && target->env_type != ZigLLVM_MSVC));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user