(Resent with CC to gcc-patches)
Hello
> I tried out the patch with one test-case and -pie -fPIC/-fpic already
> seems to works, so perhaps we could have at least one test-case
> exercising this in libgomp? That sounds easier to do than the
> shared-lib test-case.
I've created a simple testcase which tries to generate a shared library with
offloaded code. Without the mkoffload patch, it fails during linking with:
ld: /tmp/ccNaT7fO.target.o: relocation R_X86_64_32 against `.rodata' can not be
used when making a shared object; recompile with -fPIC
I have tested this on a x64 host with offloading to nvptx and gcn. On AMD GCN,
it also produces a couple of extra linker warnings that I have added dg-warning
entries for.
Okay for trunk/OG10 together with the previous mkoffload patch?
Thanks
Kwok
commit 43238117c261285a6b95d881bcc2f9efd9f752ad
Author: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Wed Jul 8 03:28:08 2020 -0700
Add test case
2020-07-08 Kwok Cheung Yeung <k...@codesourcery.com>
libgomp/
* testsuite/libgomp.oacc-c-c++-common/shared-lib.c: New.
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/shared-lib.c
b/libgomp/testsuite/libgomp.oacc-c-c++-common/shared-lib.c
new file mode 100644
index 0000000..6d8a4ac
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/shared-lib.c
@@ -0,0 +1,16 @@
+/* { dg-do link } */
+/* { dg-additional-options "-shared -fPIC" { target fpic } } */
+
+#define N 512
+
+void f(int a[])
+{
+ int i;
+
+ #pragma acc parallel
+ for (i = 0; i < N; i++)
+ a[i]++;
+}
+
+/* { dg-warning "relocation against `.*' in read-only section `\.rodata'" "" {
target openacc_radeon_accel_selected } 0 } */
+/* { dg-warning "creating DT_TEXTREL in a shared object" "" { target
openacc_radeon_accel_selected } 0 } */