mh-darwin 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # The -mdynamic-no-pic ensures that the compiler executable is built without
  2. # position-independent-code -- the usual default on Darwin. This speeds compiles
  3. # by 8-20% (measurements made against GCC-11).
  4. # However, we cannot add it unless the bootstrap compiler supports
  5. # -mno-dynamic-no-pic to undo it, since libiberty, at least, needs this.
  6. # We use Werror, since some versions of clang report unknown command line flags
  7. # as a warning only.
  8. # We only need to determine this for the host tool used to build stage1 (or a
  9. # non-bootstrapped compiler), later stages will be built by GCC which supports
  10. # the required flags.
  11. # We cannot use mdynamic-no-pic when building shared host resources.
  12. ifeq (${host_shared},no)
  13. BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := $(shell \
  14. $(CC) -S -xc /dev/null -o /dev/null -Werror -mno-dynamic-no-pic 2>/dev/null \
  15. && echo true)
  16. else
  17. BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := false
  18. endif
  19. @if gcc-bootstrap
  20. ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true)
  21. STAGE1_CFLAGS += -mdynamic-no-pic
  22. else
  23. STAGE1_CFLAGS += -fPIC
  24. endif
  25. ifeq (${host_shared},no)
  26. # Add -mdynamic-no-pic to later stages when we know it is built with GCC.
  27. BOOT_CFLAGS += -mdynamic-no-pic
  28. endif
  29. @endif gcc-bootstrap
  30. @unless gcc-bootstrap
  31. ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true)
  32. # FIXME: we should also enable this for cross and non-bootstrap builds but
  33. # that needs amendment to libcc1.
  34. # CFLAGS += -mdynamic-no-pic
  35. # CXXFLAGS += -mdynamic-no-pic
  36. else
  37. CFLAGS += -fPIC
  38. CXXFLAGS += -fPIC
  39. endif
  40. @endunless gcc-bootstrap