This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp4] Add tables generation
- From: Bernd Schmidt <bernds at codesourcery dot com>
- To: Thomas Schwinge <thomas at codesourcery dot com>
- Cc: Ilya Verbin <iverbin at gmail dot com>, Michael Zolotukhin <michael dot v dot zolotukhin at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 3 Apr 2014 18:13:08 +0200
- Subject: Re: [gomp4] Add tables generation
- Authentication-results: sourceware.org; auth=none
- References: <532B1C45 dot 9020308 at codesourcery dot com> <87vbusi3qy dot fsf at kepler dot schwinge dot homeip dot net> <87ioqsi0w8 dot fsf at kepler dot schwinge dot homeip dot net>
On 04/02/2014 10:36 AM, Thomas Schwinge wrote:
I see regressions in the libgomp testsuite for configurations where
offloading is not enabled:
spawn [...]/build/gcc/xgcc -B[...]/build/gcc/ [...]/source/libgomp/testsuite/libgomp.c/for-3.c -B[...]/build/x86_64-unknown-linux-gnu/./libgomp/ -B[...]/build/x86_64-unknown-linux-gnu/./libgomp/.libs -I[...]/build/x86_64-unknown-linux-gnu/./libgomp -I[...]/source/libgomp/testsuite/.. -fmessage-length=0 -fno-diagnostics-show-caret -fdiagnostics-color=never -fopenmp -std=gnu99 -fopenmp -L[...]/build/x86_64-unknown-linux-gnu/./libgomp/.libs -lm -o ./for-3.exe
/tmp/ccGnT0ei.o: In function `main':
for-3.c:(.text+0x21032): undefined reference to `__OPENMP_TARGET__'
collect2: error: ld returned 1 exit status
I suppose that's because [...]
Workaround committed in r209015:
libgcc/
* crtstuff.c [!ENABLE_OFFLOADING] (__OPENMP_TARGET__): Define to
NULL.
The patch below should be a better fix, making the references to
__OPENMP_TARGET__ weak. Does this work for you?
Bernd
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c (revision 429741)
+++ gcc/omp-low.c (working copy)
@@ -221,6 +221,28 @@ static tree scan_omp_1_op (tree *, int *
*handled_ops_p = false; \
break;
+static GTY(()) tree offload_symbol_decl;
+
+/* Get the __OPENMP_TARGET__ symbol. */
+static tree
+get_offload_symbol_decl (void)
+{
+ if (!offload_symbol_decl)
+ {
+ tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL,
+ get_identifier ("__OPENMP_TARGET__"),
+ ptr_type_node);
+ TREE_PUBLIC (decl) = 1;
+ DECL_EXTERNAL (decl) = 1;
+ DECL_WEAK (decl) = 1;
+ DECL_ATTRIBUTES (decl)
+ = tree_cons (get_identifier ("weak"),
+ NULL_TREE, DECL_ATTRIBUTES (decl));
+ offload_symbol_decl = decl;
+ }
+ return offload_symbol_decl;
+}
+
/* Convenience function for calling scan_omp_1_op on tree operands. */
static inline tree
@@ -5148,11 +5170,7 @@ expand_oacc_offload (struct omp_region *
}
gimple g;
- tree openmp_target
- = build_decl (UNKNOWN_LOCATION, VAR_DECL,
- get_identifier ("__OPENMP_TARGET__"), ptr_type_node);
- TREE_PUBLIC (openmp_target) = 1;
- DECL_EXTERNAL (openmp_target) = 1;
+ tree openmp_target = get_offload_symbol_decl ();
tree fnaddr = build_fold_addr_expr (child_fn);
g = gimple_build_call (builtin_decl_explicit (start_ix), 10, device,
fnaddr, build_fold_addr_expr (openmp_target),
@@ -8686,11 +8704,7 @@ expand_omp_target (struct omp_region *re
}
gimple g;
- tree openmp_target
- = build_decl (UNKNOWN_LOCATION, VAR_DECL,
- get_identifier ("__OPENMP_TARGET__"), ptr_type_node);
- TREE_PUBLIC (openmp_target) = 1;
- DECL_EXTERNAL (openmp_target) = 1;
+ tree openmp_target = get_offload_symbol_decl ();
if (kind == GF_OMP_TARGET_KIND_REGION)
{
tree fnaddr = build_fold_addr_expr (child_fn);