From 033ec967ec5583ea978d16ca83f9563c518e6dc6 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 12 Feb 2022 14:54:21 -0800 Subject: compiler: don't set ptrmask bit for pointer to notinheap type Test case is https://go.dev/cl/385454. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385474 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gofrontend/types.cc | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'gcc/go') diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 4e6bac7..02a6e1d 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -47380f733ca932384e59492d2f04374edd8ec95e +7f8fee099d6de4a5a857765e0ddfae356ead554c The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index ee34676..8267f15 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -2816,6 +2816,9 @@ class Ptrmask void Ptrmask::set_from(Gogo* gogo, Type* type, int64_t ptrsize, int64_t offset) { + if (!type->has_pointer()) + return; + switch (type->base()->classification()) { default: @@ -2858,9 +2861,6 @@ Ptrmask::set_from(Gogo* gogo, Type* type, int64_t ptrsize, int64_t offset) case Type::TYPE_STRUCT: { - if (!type->has_pointer()) - return; - const Struct_field_list* fields = type->struct_type()->fields(); int64_t soffset = 0; for (Struct_field_list::const_iterator pf = fields->begin(); @@ -2898,9 +2898,6 @@ Ptrmask::set_from(Gogo* gogo, Type* type, int64_t ptrsize, int64_t offset) } else { - if (!type->has_pointer()) - return; - int64_t len; if (!type->array_type()->int_length(&len)) { -- cgit v1.1 From 58aeb75d4097010ad9bb72b964265b18ab284f93 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 12 Feb 2022 17:12:41 -0800 Subject: runtime: call timer functions via syscall It turns out to be painful to require linking against -lrt on GNU/Linux, as that makes it harder to link Go code into C programs. Instead just call the timer syscalls directly. That is what the upstream library does anyhow. gcc/go/ * gospec.cc: Revert 2022-02-09 change: (RTLIB, RT_LIBRARY): Don't define. (lang_specific_driver): Don't add -lrt if linking statically on GNU/Linux. gotools/ * configure.ac: Revert 2022-02-09 change: (RT_LIBS): Don't define. * Makefile.am (check-runtime): Don't set GOLIBS to $(RT_LIBS). * configure, Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385475 --- gcc/go/gofrontend/MERGE | 2 +- gcc/go/gospec.cc | 42 +++++------------------------------------- 2 files changed, 6 insertions(+), 38 deletions(-) (limited to 'gcc/go') diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 02a6e1d..745132a 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -7f8fee099d6de4a5a857765e0ddfae356ead554c +0af68c0552341a44f1fb12301f9eff954b9dde88 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc index ba7ba4e..df92b62 100644 --- a/gcc/go/gospec.cc +++ b/gcc/go/gospec.cc @@ -29,12 +29,10 @@ along with GCC; see the file COPYING3. If not see #define MATHLIB (1<<2) /* This bit is set if they did `-lpthread'. */ #define THREADLIB (1<<3) -/* This bit is set if they did `-lrt'. */ -#define RTLIB (1<<4) /* This bit is set if they did `-lc'. */ -#define WITHLIBC (1<<5) +#define WITHLIBC (1<<4) /* Skip this option. */ -#define SKIPOPT (1<<6) +#define SKIPOPT (1<<5) #ifndef MATH_LIBRARY #define MATH_LIBRARY "m" @@ -46,8 +44,6 @@ along with GCC; see the file COPYING3. If not see #define THREAD_LIBRARY "pthread" #define THREAD_LIBRARY_PROFILE THREAD_LIBRARY -#define RT_LIBRARY "rt" - #define LIBGO "go" #define LIBGO_PROFILE LIBGO #define LIBGOBEGIN "gobegin" @@ -78,9 +74,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* "-lpthread" if it appears on the command line. */ const struct cl_decoded_option *saw_thread = 0; - /* "-lrt" if it appears on the command line. */ - const struct cl_decoded_option *saw_rt = 0; - /* "-lc" if it appears on the command line. */ const struct cl_decoded_option *saw_libc = 0; @@ -91,9 +84,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Whether we need the thread library. */ int need_thread = 0; - /* Whether we need the rt library. */ - int need_rt = 0; - /* By default, we throw on the math library if we have one. */ int need_math = (MATH_LIBRARY[0] != '\0'); @@ -166,8 +156,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, } else if (strcmp (arg, THREAD_LIBRARY) == 0) args[i] |= THREADLIB; - else if (strcmp (arg, RT_LIBRARY) == 0) - args[i] |= RTLIB; else if (strcmp (arg, "c") == 0) args[i] |= WITHLIBC; else @@ -272,7 +260,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, #endif /* Make sure to have room for the trailing NULL argument. */ - num_args = argc + need_math + shared_libgcc + (library > 0) * 6 + 10; + num_args = argc + need_math + shared_libgcc + (library > 0) * 5 + 10; new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args); i = 0; @@ -326,12 +314,6 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, saw_thread = &decoded_options[i]; } - if (!saw_rt && (args[i] & RTLIB) && library > 0) - { - --j; - saw_rt = &decoded_options[i]; - } - if (!saw_libc && (args[i] & WITHLIBC) && library > 0) { --j; @@ -413,23 +395,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, #endif /* When linking libgo statically we also need to link with the - pthread and (on GNU/Linux) the rt library. */ + pthread library. */ if (library > 1 || static_link) - { - need_thread = 1; - if (strstr (DEFAULT_TARGET_MACHINE, "linux") != NULL) - need_rt = 1; - } - } - - if (saw_rt) - new_decoded_options[j++] = *saw_rt; - else if (library > 0 && need_rt) - { - generate_option (OPT_l, RT_LIBRARY, 1, CL_DRIVER, - &new_decoded_options[j]); - added_libraries++; - j++; + need_thread = 1; } if (saw_thread) -- cgit v1.1