This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Default ppc64 linux-gnu/freebsd to -fno-PIC
ClosedPublic

Authored by MaskRay on Jan 7 2020, 2:39 PM.

Details

Summary

According to D53384, the default was switched from -fno-PIC to -fPIC to
work around a -fsanitize=leak bug on big-endian.

This gratuitous difference between little-endian and big-endian is
undesired, and not acceptable on powerpc64-unknown-freebsd. If
-fsanitize=leak still has the problem, we should default to -fPIC/-fPIE
only when -fsanitize=leak is specified.

powerpc64-ibm-aix is unaffected: it still defaults to -fPIC.
powerpc64-linux-musl is unaffected: it still defaults to -fPIE.

Diff Detail

Event Timeline

MaskRay created this revision.Jan 7 2020, 2:39 PM
jhibbits accepted this revision.Jan 7 2020, 2:49 PM
This revision is now accepted and ready to land.Jan 7 2020, 2:49 PM

I am definitely in favor of this change, as the defaulting to PIC has been causing headaches in the FreeBSD kernel.

Unit tests: pass. 61304 tests passed, 0 failed and 736 were skipped.

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

This revision was automatically updated to reflect the committed changes.

LGTM: I really didn't like setting PIC as the default just to work around some codegen bugs. I believe there are PowerPC codegen tests that will fail with this change though (or perhaps there is a PowerPC leak sanitizer build bot which begins to fail? @stefanp probably knows what exposed the BE issue previously).

A couple minor questions though: Is there a way to emit a warning if the leak sanitizer is used on ELF powerpc64 and PIC/PIE is not also specified? Where should we document that the leak sanitizer needs additional options for a specific target?

LGTM: I really didn't like setting PIC as the default just to work around some codegen bugs. I believe there are PowerPC codegen tests that will fail with this change though (or perhaps there is a PowerPC leak sanitizer build bot which begins to fail? @stefanp probably knows what exposed the BE issue previously).

A couple minor questions though: Is there a way to emit a warning if the leak sanitizer is used on ELF powerpc64 and PIC/PIE is not also specified? Where should we document that the leak sanitizer needs additional options for a specific target?

Some sanitizers default to -fPIE. It -fsanitize=leak still has the bug and there is a desire (imho this is not a very good idea to make BE/LE gratuitously different), getSanitizerArgs().requiresPIE() can be a candidate to patch:

bool Linux::isPIEDefault() const {
  return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
          getTriple().isMusl() || getSanitizerArgs().requiresPIE();
}