diff mbox series

[2/2] libphobos: don't compile empty switchcontext.S

Message ID 20211220000831.332831-2-alex_y_xu@yahoo.ca
State New
Headers show
Series [1/2] libphobos: fix CET for non-glibc targets | expand

Commit Message

Alex Xu \(Hello71\) Dec. 20, 2021, 12:08 a.m. UTC
If it does not contain any files, then there is no point compiling it.
Skipping this saves some milliseconds and ~650 bytes in libgphobos.a.
---
 libphobos/configure.ac                        |  1 +
 libphobos/libdruntime/Makefile.am             |  2 ++
 .../libdruntime/config/x86/switchcontext.S    | 25 ++++++-------------
 3 files changed, 11 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index c961e68105a..7169f016ffe 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -78,6 +78,7 @@  AS_IF([test x$enable_cet = xyes], [
 ])
 AC_SUBST(CET_DFLAGS)
 AC_SUBST(DCFG_ENABLE_CET)
+AM_CONDITIONAL([ENABLE_CET], [test x$enable_cet = xyes])
 
 # This should be inherited in the recursive make, but ensure it is defined.
 test "$AR" || AR=ar
diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
index 224d06e78ca..77d7934e705 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -93,9 +93,11 @@  if DRUNTIME_CPU_X86
 if DRUNTIME_OS_MINGW
     DRUNTIME_SOURCES_CONFIGURED += config/mingw/switchcontext.S
 else
+if !ENABLE_CET
     DRUNTIME_SOURCES_CONFIGURED += config/x86/switchcontext.S
 endif
 endif
+endif
 if DRUNTIME_CPU_SYSTEMZ
     DRUNTIME_SOURCES_CONFIGURED += config/systemz/get_tls_offset.S
 endif
diff --git a/libphobos/libdruntime/config/x86/switchcontext.S b/libphobos/libdruntime/config/x86/switchcontext.S
index 9f4befdb49c..adc46a3b89d 100644
--- a/libphobos/libdruntime/config/x86/switchcontext.S
+++ b/libphobos/libdruntime/config/x86/switchcontext.S
@@ -24,16 +24,9 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include "../common/threadasm.S"
 
-/* NB: Generate the CET marker for -fcf-protection.  */
-#ifdef __CET__
-# include <cet.h>
-#endif
+#if defined(__ELF__)
 
-#if !defined(__CET__)
-
-# if defined(__ELF__)
-
-#  if defined(__i386__)
+# if defined(__i386__)
 
     .text
     .globl CSYM(fiber_switchContext)
@@ -104,13 +97,13 @@  CSYM(fiber_switchContext):
     .cfi_endproc
    .size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
 
-#  endif /* defined(__ELF__) && defined(__x86_64__) && !defined(__ILP32__) */
+# endif /* defined(__ELF__) && defined(__x86_64__) && !defined(__ILP32__) */
 
-# endif /* defined(__ELF__) */
+#endif /* defined(__ELF__) */
 
-# if defined(__MACH__)
+#if defined(__MACH__)
 
-#  if defined(__i386__)
+# if defined(__i386__)
 
     .text
     .globl CSYM(fiber_switchContext)
@@ -247,8 +240,6 @@  LASFDE1:
         .p2align 3,0
 LEFDE1:
 
-#  endif /* defined(__MACH__) && defined(__x86_64__) && !defined(__ILP32__) */
+# endif /* defined(__MACH__) && defined(__x86_64__) && !defined(__ILP32__) */
 
-# endif /* defined (__MACH__) */
-
-#endif /* !defined(__CET__) */
+#endif /* defined (__MACH__) */