OpenMP Runtime testcase failures with -fno-PIC
| Bugzilla Link | 40082 |
| Version | unspecified |
| OS | Linux |
| CC | @hahnjo,@hfinkel |
Extended Description
The following tests fail if run with -fno-PIC on PowerPC on Little Endian Linux.
openmp/runtime/test/ompt/misc/control_tool.c openmp/runtime/test/ompt/synchronization/taskwait.c
Once we switch to no-PIC default for PowerPC Little Endian Linux these tests will be XFAILED on that platform.
Investigation is required here to fund out why they behave differently under no-PIC.
In that case, if you don't mind, I will put up the patch on Phabricator. I'll try to find a PowerPC OpenMP person to review it and if it gets accepted I'll commit. Is that ok with you?
Yes, sounds good. Thanks!
In that case, if you don't mind, I will put up the patch on Phabricator. I'll try to find a PowerPC OpenMP person to review it and if it gets accepted I'll commit. Is that ok with you?
I'm not an OpenMP person, I just happened to find this issue when I was working on PIC/no-PIC, so I'm not really the right person to do a proper review of your patch but as far as I can tell this looks good to me.
I'm not a PPC person and I'm not going to send this patch in without any possibility to test it myself, I didn't break the tests and bots.
I've tried your patch and everything seems to be working properly now when I remove the XFAIL on those two test cases. I'm not an OpenMP person, I just happened to find this issue when I was working on PIC/no-PIC, so I'm not really the right person to do a proper review of your patch but as far as I can tell this looks good to me.
Yes, I have seen that the OpenMP buildbot is failing on PowerPC LE Linux. This appears to actually be an issue with the buildbot itself. The tests are failing on the buildbot because the bot is not taking the XFAIL into consideration. I'm currently talking to the owner of the buildbot to try to get that fixed. Hopefully this will be resolved soon.
I just had an idea and I think the issue is somewhere else: r349512 tries to use the CMake variable TARGET_TRIPLE. This is defined in LLVM's CMake logic, so it's simply not available when building and testing in standalone mode which the bots do. (However, it works when building the runtime in-tree which is probably why you didn't see the problems.)
You are correct that the tests will be marked as unexpected pass if we run them with -fPIC on powerPC64LE. However, this is no different than before when we had them use the default -fPIC and expected them to pass. If someone were to try -fno-PIC on the previous test cases they would have failed (which is why I opened this bug). Since we changed the default on PowerPC LE from -fPIC to -fno-PIC I was just updating the tests accordingly. The bug has been there throughout.
I think there is an important difference: Up to now -fno-PIC would have been a manual change. However, the newly added XFAILs will fail with all currently released Clang versions which we usually strive to support. So while I agree that failing tests with Clang trunk are bad, I also think that the current situation isn't ideal either.
So to tackle the root cause: I had a look at the generated assembly code for PowerPC and there seems to be an additional store because omp_control_tool and __kmpc_omp_taskwait return an integer. This hasn't been the case for -fPIC, but it's similar to x86. Can you try the following patch?
diff --git a/runtime/test/ompt/callback.h b/runtime/test/ompt/callback.h index 0304cff..ab2cf2b 100755 --- a/runtime/test/ompt/callback.h +++ b/runtime/test/ompt/callback.h @@ -151,11 +151,12 @@ ompt_label_##id: ompt_get_thread_data()->value, ((char *)addr) - 1, ((char *)addr) - 4) #elif KMP_ARCH_PPC64 // On Power the NOP instruction is 4 bytes long. In addition, the compiler -// inserts an LD instruction which accounts for another 4 bytes. In contrast to -// X86 this instruction is always there, even for void runtime functions. +// inserts a second NOP instruction (another 4 bytes). For non-void runtime +// functions Clang inserts a STW instruction (but only if compiling under +// -fno-PIC which will be the default with Clang 8.0, another 4 bytes). #define print_possible_return_addresses(addr) \
- printf("%" PRIu64 ": current_address=%p\n", ompt_get_thread_data()->value, \
-
((char *)addr) - 8)
- printf("%" PRIu64 ": current_address=%p or %p\n", ompt_get_thread_data()->value, \
-
((char *)addr) - 8, ((char *)addr) - 12)
#elif KMP_ARCH_AARCH64 // On AArch64 the NOP instruction is 4 bytes long, can be followed by inserted // store instruction (another 4 bytes long).
Yes, I have seen that the OpenMP buildbot is failing on PowerPC LE Linux. This appears to actually be an issue with the buildbot itself. The tests are failing on the buildbot because the bot is not taking the XFAIL into consideration. I'm currently talking to the owner of the buildbot to try to get that fixed. Hopefully this will be resolved soon.
You are correct that the tests will be marked as unexpected pass if we run them with -fPIC on powerPC64LE. However, this is no different than before when we had them use the default -fPIC and expected them to pass. If someone were to try -fno-PIC on the previous test cases they would have failed (which is why I opened this bug). Since we changed the default on PowerPC LE from -fPIC to -fno-PIC I was just updating the tests accordingly. The bug has been there throughout.
Anyway, hope that helps...
I see that you marked the two tests as XFAIL in r349512 and r349521. This probably means they will be marked as 'Unexpected passes' if you compile them with '-fPIC'? Moreover the public build bot is failing since this change, see http://lab.llvm.org:8011/builders/openmp-clang-ppc64le-linux-rhel/builds/96
P.S.: Please make sure to subscribe to openmp-commits. Otherwise your commit mails will be stuck in moderation which makes it moderately hard to notice the changes.