configure: detect PIE and enable PIC
authorJames Zern <jzern@google.com>
Mon, 6 Nov 2023 18:21:56 +0000 (10:21 -0800)
committerJames Zern <jzern@google.com>
Mon, 6 Nov 2023 23:17:19 +0000 (15:17 -0800)
Fixes the creation of DT_TEXTREL entries in binaries built with PIE
enabled:
  /usr/bin/ld: warning: creating DT_TEXTREL in a PIE

This matches the changes made in libaom:
1df26009da aom_configure: only override CONFIG_PIC if not set on cmd line
7235e65746 aom_configure.cmake: detect PIE and set CONFIG_PIC

Change-Id: I0a43e964af2d8eb8c5e7811ce14ad39285eec3a8

build/make/configure.sh

index 9d3cd80..54fb1da 100644 (file)
@@ -863,8 +863,14 @@ process_common_toolchain() {
       ;;
   esac
 
-  # PIC is probably what we want when building shared libs
+  # Position independent code (PIC) is probably what we want when building
+  # shared libs or position independent executable (PIE) targets.
   enabled shared && soft_enable pic
+  check_cpp << EOF || soft_enable pic
+#if !(__pie__ || __PIE__)
+#error Neither __pie__ or __PIE__ are set
+#endif
+EOF
 
   # Minimum iOS version for all target platforms (darwin and iphonesimulator).
   # Shared library framework builds are only possible on iOS 8 and later.