In, https://reviews.llvm.org/D120305, CLANG_DEFAULT_PIE_ON_LINUX was set
to On by default. However, neither -fpie nor -fpic are currently
supported in LLVM Flang. Hence, in this patch, the behavior controlled
with CLANG_DEFAULT_PIE_ON_LINUX is refined not to apply to Flang.
Another way to look at this is that CLANG_DEFAULT_PIE_ON_LINUX is
currently affecting both Clang and Flang. However, IIUC, the intention for this
CMake variable has always been to only apply to Clang. This patch makes
sure that that's indeed the case.
Without this change, you might see errors like this on X86_64:
/usr/bin/ld: main.o: relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
I've not experienced any issues on AArch64. That's probably because on
AArch64 some object files happen to be position independent without
needing -fpie or -fpic.
We can revisit this once support for -fpie and -fpic is available in LLVM Flang.
I'm not aware of anyone actively working in this area.
The ! RUN COMMANDS and EXPECTED OUTPUT comments seem rather redundant. I'd remove them.