Skip to content

Commit b78b210

Browse files
committed
rts: Better AutoApply logic
1 parent 3183a19 commit b78b210

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
lines changed

rts/AutoApply.cmm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <rts/AutoApply.cmm.h>

rts/AutoApply_V16.cmm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <rts/AutoApply_V16.cmm.h>

rts/AutoApply_V32.cmm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <rts/AutoApply_V32.cmm.h>

rts/AutoApply_V64.cmm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <rts/AutoApply_V64.cmm.h>

rts/configure.ac

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -583,36 +583,36 @@ else
583583
AC_MSG_ERROR([Failed to run $DERIVE_CONSTANTS --gen-header ...])
584584
fi
585585

586-
AC_MSG_CHECKING([for AutoApply.cmm])
587-
if $GENAPPLY include/DerivedConstants.h > AutoApply.cmm; then
586+
AC_MSG_CHECKING([for include/rts/AutoApply.cmm.h])
587+
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h > include/rts/AutoApply.cmm.h; then
588588
AC_MSG_RESULT([created])
589589
else
590590
AC_MSG_RESULT([failed to create])
591-
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h > AutoApply.cmm])
591+
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h > include/rts/AutoApply.cmm.h])
592592
fi
593593

594-
AC_MSG_CHECKING([for AutoApply_V16.cmm])
595-
if $GENAPPLY include/DerivedConstants.h -V16 > AutoApply_V16.cmm; then
594+
AC_MSG_CHECKING([for include/rts/AutoApply_V16.cmm.h])
595+
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h -V16 > include/rts/AutoApply_V16.cmm.h; then
596596
AC_MSG_RESULT([created])
597597
else
598598
AC_MSG_RESULT([failed to create])
599-
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V16 > AutoApply_V16.cmm])
599+
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V16 > include/rts/AutoApply_V16.cmm.h])
600600
fi
601601

602-
AC_MSG_CHECKING([for AutoApply_V32.cmm])
603-
if $GENAPPLY include/DerivedConstants.h -V32 > AutoApply_V32.cmm; then
602+
AC_MSG_CHECKING([for include/rts/AutoApply_V32.cmm.h])
603+
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h -V32 > include/rts/AutoApply_V32.cmm.h; then
604604
AC_MSG_RESULT([created])
605605
else
606606
AC_MSG_RESULT([failed to create])
607-
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V32 > AutoApply_V32.cmm])
607+
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V32 > include/rts/AutoApply_V32.cmm.h])
608608
fi
609609

610-
AC_MSG_CHECKING([for AutoApply_V64.cmm])
611-
if $GENAPPLY include/DerivedConstants.h -V64 > AutoApply_V64.cmm; then
610+
AC_MSG_CHECKING([for include/rts/AutoApply_V64.cmm.h])
611+
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h -V64 > include/rts/AutoApply_V64.cmm.h; then
612612
AC_MSG_RESULT([created])
613613
else
614614
AC_MSG_RESULT([failed to create])
615-
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V64 > AutoApply_V64.cmm])
615+
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V64 > include/rts/AutoApply_V64.cmm.h])
616616
fi
617617

618618
AC_MSG_CHECKING([for include/rts/EventLogConstants.h])

rts/rts.cabal

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,25 +340,28 @@ common rts-cmm-sources-base
340340
-- then have the `AutoApply.cmm` in `rts-c-sources-base` include them. This
341341
-- would mean they are included in the sublibraries which will in turn apply
342342
-- the sublibrary specific (c)flags.
343-
autogen-cmm-sources:
343+
cmm-sources:
344344
AutoApply.cmm
345345
AutoApply_V16.cmm
346346

347347
if arch(x86_64)
348348
cmm-sources:
349349
Jumps_V32.cmm (-mavx2)
350350
Jumps_V64.cmm (-mavx512f)
351-
autogen-cmm-sources:
352351
AutoApply_V32.cmm (-mavx2)
353352
AutoApply_V64.cmm (-mavx512f)
354353
else
355354
cmm-sources:
356355
Jumps_V32.cmm
357356
Jumps_V64.cmm
358-
autogen-cmm-sources:
359357
AutoApply_V32.cmm
360358
AutoApply_V64.cmm
361359

360+
-- this is required so we don't have ghc inject ghc-internal (which depends on the rts)
361+
-- during the build phase of this library.
362+
ghc-options: -no-ghc-internal
363+
364+
362365
common rts-c-sources-base
363366
if !arch(javascript)
364367
cmm-sources:
@@ -637,19 +640,42 @@ library
637640
ghc-options: -this-unit-id rts -ghcversion-file=include/ghcversion.h -optc-DFS_NAMESPACE=rts
638641
cmm-options: -this-unit-id rts
639642

643+
-- [The AutoApply story]
644+
--
645+
-- We use GenApply to generate the AutoApply[_V{16,32,64}].cmm files.
646+
-- However cabal will run the ./configure script only for the main library.
647+
-- To work around this shortcoming, we'll generate .cmm.h files (same
648+
-- content as .cmm), and create AutoApply*.cmm files that just
649+
--
650+
-- #include <rts/AutoApply_...cmm.h>
651+
--
652+
-- This way each sublib has it's own properly parameterized .cmm file, while
653+
-- we only generate them once and stick them into the rts library.
654+
--
655+
-- This is a hack, and it would be great if sublibs had access to their
656+
-- parent libraries auto-gen folders, however as sublibs are supposed to be
657+
-- separate components, this is a non-trivial (impossible?) task to resolve.
640658
autogen-includes:
641659
ghcautoconf.h
642660
ghcplatform.h
643661
DerivedConstants.h
644662
rts/EventLogConstants.h
645663
rts/EventTypes.h
664+
AutoApply.cmm.h
665+
AutoApply_V16.cmm.h
666+
AutoApply_V32.cmm.h
667+
AutoApply_V64.cmm.h
646668

647669
install-includes:
648670
ghcautoconf.h
649671
ghcplatform.h
650672
DerivedConstants.h
651673
rts/EventLogConstants.h
652674
rts/EventTypes.h
675+
AutoApply.cmm.h
676+
AutoApply_V16.cmm.h
677+
AutoApply_V32.cmm.h
678+
AutoApply_V64.cmm.h
653679

654680
install-includes:
655681
-- Common headers for non-JS builds
@@ -771,10 +797,8 @@ library nonthreaded-nodebug
771797
import: rts-base-config, rts-cmm-sources-base, rts-c-sources-base, rts-link-options, rts-global-build-flags
772798

773799
visibility: public
774-
775800
ghc-options: -optc-DRtsWay="v"
776801

777-
778802
library threaded-nodebug
779803
import: rts-base-config, rts-cmm-sources-base, rts-c-sources-base, rts-link-options, rts-global-build-flags, rts-threaded-flags
780804
visibility: public

0 commit comments

Comments
 (0)