Bug 1389276

Summary: Linking errors on aarch64 for OpenMP enabled application - R_AARCH64_ABS64 used with TLS symbol work_lhs_
Product: Red Hat Enterprise Linux 7 Reporter: Petr Sury <psury>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: jakub, jbastian, jfeeney, jhladky, mcermak, mnewsome, mpetlan, mpolacek, psury, yselkowi
Target Milestone: rc   
Target Release: 7.4   
Hardware: aarch64   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-4.8.5-12.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 22:35:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1357680, 1413146    
Attachments:
Description Flags
Log
none
reproducer.sh
none
Better reproducer none

Description Petr Sury 2016-10-27 10:42:00 UTC
Created attachment 1214571 [details]
Log

Hi all,
compiling openmp benchmark on arm with current gcc fails. See attached log for more information.

Comment 1 Petr Sury 2016-10-27 10:49:47 UTC
Created attachment 1214572 [details]
reproducer.sh

Script for installing NAS benchmark which then tries to compile one of sub-benchmarks, compiling fails which shows the problem.

Comment 3 Jiri Hladky 2016-10-27 12:19:50 UTC
We have tested it with following gcc versions:

gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC) 
gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) 

Both versions have the same problem. Please note that problem is visible only when compiling with -fopenmp 

I will paste the attachment 1214571 [details] directly here:
=====================================================
$ which gcc
/opt/rh/devtoolset-6/root/usr/bin/gcc
05:24:43 root.eng.rdu.redhat.com: /mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-6/root/usr --mandir=/opt/rh/devtoolset-6/root/usr/share/man --infodir=/opt/rh/devtoolset-6/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-6.2.1-20160916/obj-aarch64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC)
05:24:52 root.eng.rdu.redhat.com: /mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources
$ make bt CLASS=C
   ============================================
   =      NAS PARALLEL BENCHMARKS 3.3         =
   =      OpenMP Versions                     =
   =      F77/C                               =
   ============================================

cd BT; make CLASS=C VERSION=
make[1]: Entering directory '/mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources/BT'
make[2]: Entering directory '/mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources/sys'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources/sys'
../sys/setparams bt C
make[2]: Entering directory '/mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources/BT'
gfortran -O3 -fopenmp -mcmodel=large -o ../bin/bt.C.x bt.o  initialize.o exact_solution.o exact_rhs.o set_constants.o adi.o  rhs.o x_solve.o y_solve.o solve_subs.o z_solve.o add.o error.o verify.o ../common/print_results.o ../common/timers.o ../common/wtime.o
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: exact_rhs.o(.text+0x2470): R_AARCH64_ABS64 used with TLS symbol work_1d_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: x_solve.o(.text+0x1528): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: x_solve.o(.text+0x1530): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: x_solve.o(.text+0x1538): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: y_solve.o(.text+0x1588): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: y_solve.o(.text+0x1590): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: y_solve.o(.text+0x1598): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: z_solve.o(.text+0x1658): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: z_solve.o(.text+0x1660): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: z_solve.o(.text+0x1668): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: ../common/timers.o(.text+0x20): R_AARCH64_ABS64 used with TLS symbol tt_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: ../common/timers.o(.text+0x58): R_AARCH64_ABS64 used with TLS symbol tt_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: ../common/timers.o(.text+0xa8): R_AARCH64_ABS64 used with TLS symbol tt_
/opt/rh/devtoolset-6/root/usr/libexec/gcc/aarch64-redhat-linux/6.2.1/ld: ../common/timers.o(.text+0xc8): R_AARCH64_ABS64 used with TLS symbol tt_
make[2]: Leaving directory '/mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources/BT'
make[1]: Leaving directory '/mnt/tests/performance/NAS_parallel_benchmark-test/certification/NPB_sources/BT'
=====================================================

Comment 4 Petr Sury 2016-10-27 14:29:29 UTC
Created attachment 1214626 [details]
Better reproducer

To reproduce described problem, please download attached tar, untar it and execute reproducer.sh

Comment 6 Michael Petlan 2016-11-15 00:49:37 UTC
Hi Petr. Could you please specify what exactly is the problem? I am able to get the messages mentioned in the bug name, however, the linking process returns 0 and creates the target executable which seems to run somehow. Are the "R_AARCH64_ABS64 used with TLS symbol work_lhs_" messages the issue? What is the desired state? Thanks!


[root@aarch64 BT]# gfortran -O3 -fopenmp -mcmodel=large -o ../bin/bt.C.x bt.o  initialize.o exact_solution.o exact_rhs.o set_constants.o adi.o  rhs.o x_solve.o y_solve.o solve_subs.o z_solve.o add.o error.o verify.o ../common/print_results.o ../common/timers.o ../common/wtime.o
/usr/bin/ld: exact_rhs.o(.text+0x2458): R_AARCH64_ABS64 used with TLS symbol work_1d_
/usr/bin/ld: x_solve.o(.text+0x15b8): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: x_solve.o(.text+0x15c0): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: x_solve.o(.text+0x15c8): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: x_solve.o(.text+0x15d8): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: y_solve.o(.text+0x1618): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: y_solve.o(.text+0x1620): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: y_solve.o(.text+0x1628): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: y_solve.o(.text+0x1638): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: z_solve.o(.text+0x1658): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: z_solve.o(.text+0x1660): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: z_solve.o(.text+0x1668): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: z_solve.o(.text+0x1678): R_AARCH64_ABS64 used with TLS symbol work_lhs_
/usr/bin/ld: ../common/timers.o(.text+0x20): R_AARCH64_ABS64 used with TLS symbol tt_
/usr/bin/ld: ../common/timers.o(.text+0x58): R_AARCH64_ABS64 used with TLS symbol tt_
/usr/bin/ld: ../common/timers.o(.text+0xa8): R_AARCH64_ABS64 used with TLS symbol tt_
/usr/bin/ld: ../common/timers.o(.text+0xc8): R_AARCH64_ABS64 used with TLS symbol tt_
[root@aarch64 BT]# echo $?
0
[root@aarch64 BT]# ls ../bin
bt.C.x

Comment 7 Petr Sury 2016-11-18 11:59:16 UTC
Hi Michael,
  yes, it seems target is created, but when I try run it, it always crashes on segmentation fault. This problem I've seen only when those error messages appear. So I think these are connected. I am sorry that I missed this behaviour before.

Comment 8 Michael Petlan 2016-12-07 18:12:48 UTC
Yes, I can see the segmentation fault you describe.

# ./bin/bt.C.x 


 NAS Parallel Benchmarks (NPB3.3-OMP) - BT Benchmark

 No input file inputbt.data. Using compiled defaults
 Size:  162x 162x 162
 Iterations:  200       dt:   0.0001000


Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x3FF8E1470AB
#1  0x3FF8E147723
#2  0x3FF8E27050F
#3  0x432874 in timer_clear_ at :?
#4  0x401983 in MAIN__ at bt.f:131
Segmentation fault


Jakub, could you please have a look at this? The target app is needed for kernel scheduler performance tests. If you need, I have a box where I can reproduce the issue. Thank you in advance.

Comment 9 Jakub Jelinek 2016-12-13 16:23:52 UTC
GCC < 6.3 just doesn't support TLS in -mcmodel=large on aarch64 apparently.
If the PR78796 patch is approved, it could be easily backported to 4.8-RH.

Comment 10 Jiri Hladky 2016-12-14 16:46:16 UTC
Hi Jakub,

thanks for the update. We have tried to use Developer Toolset as the workaround 

http://download-ipv4.eng.brq.redhat.com/rel-eng/RHSCL-2.3-RHEL-7-RC-1.1/compose/Server/aarch64/os/Packages/

but it has GCC 6.2. Now it's clear why it hasn't helped. We need at least GCC 6.3.

@Peter - I think you have tried to use -mcmodel=small as well. Could yuo please post the results here?

Thanks
Jirka

Comment 11 Petr Sury 2017-01-11 16:19:08 UTC
Hi all,
  each subtest in benchmark has several classes (test problem sizes) and for lower classes (smaller test problem sizes) -ncmodel=small helped.

Comment 12 Petr Sury 2017-02-01 14:28:41 UTC
Hello everyone,
  as I mentioned before, -ncmodel=small works for small test sizes - A, B and C (excluding ft and dc test) (for test sizes please look here -> [1] ). Unfortunately for our testing we need at least C class for all subtests and sometimes (when we have a lot of RAM available) D class is needed and in that case -ncmodel=small is not sufficient.

(In reply to Jakub Jelinek from comment #9)
> GCC < 6.3 just doesn't support TLS in -mcmodel=large on aarch64 apparently.
> If the PR78796 patch is approved, it could be easily backported to 4.8-RH.

  Is there any update regarding PR78796 patch approval? 

[1] https://www.nas.nasa.gov/publications/npb_problem_sizes.html

Comment 13 Petr Sury 2017-02-13 08:50:58 UTC
Hello again everyone,
  our problem was solved by installing gcc from RHSCL-2.4-RHEL-7-Alpha-1.1. It seems that everything works but compiling LU benchmark takes about 45 minutes which appears to be quite a long time to compile such small benchmark. For this matter I am going to open dedicated BZ soon.

Comment 15 Michael Petlan 2017-06-05 14:42:05 UTC
Testing with gcc-4.8.5-16.el7.aarch64...

The related test in testsuite passes and it also works with the steps from comment #6 and comment #8. The wanted binary ./bin/bt.C.x is created without errors and it does not segfault anymore.

Test-covered in the upstream testsuite.

VERIFIED.

Comment 16 Jiri Hladky 2017-06-05 15:18:55 UTC
(In reply to Michael Petlan from comment #15)
> Testing with gcc-4.8.5-16.el7.aarch64...
> 
> The related test in testsuite passes and it also works with the steps from
> comment #6 and comment #8. The wanted binary ./bin/bt.C.x is created without
> errors and it does not segfault anymore.
> 
> Test-covered in the upstream testsuite.
> 
> VERIFIED.

Thanks a lot to everybody who has contributed to the fix!

Jirka

Comment 17 errata-xmlrpc 2017-08-01 22:35:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2094