Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Make it work (almost) on gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Scott committed Dec 8, 2015
1 parent 8a577fb commit 60f1837
Show file tree
Hide file tree
Showing 46 changed files with 16,783 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -68,3 +68,4 @@ compiler/version.sml
# /runtime
/runtime/Makefile
/runtime/Makefile.in
/runtime/ghc/*.a
5 changes: 3 additions & 2 deletions Makefile.in
@@ -1,3 +1,4 @@
include ihc-makefile.inc
include hrc-makefile.inc

IHC_PREFIX=@prefix@
HRC_PREFIX=@prefix@
PLATFORM_CPPFLAGS=@PLATFORM_CPPFLAGS@
2 changes: 1 addition & 1 deletion compiler/as-to-mil/ghc-prim.sml
Expand Up @@ -83,7 +83,7 @@ struct
type argsAndTyps = (Mil.simple * Mil.typ) list
type block = HsToMilUtils.MS.t

val pkgName = "ihc/plsr-prims-ghc"
val pkgName = "hrc/plsr-prims-ghc"
(* mil types *)
val boolTyp = M.TBoolean
val int64ArbTyp = IntArb.T (IntArb.S64, IntArb.Signed)
Expand Down
21 changes: 15 additions & 6 deletions compiler/back-end/back-end.sml
Expand Up @@ -28,11 +28,10 @@ struct
val name = "BackEnd"
val indent = 0
end)

(*
val runtimeDirectory =
fn config => Path.snoc (Config.home config, "runtime")
(*
val iflcLibDirectory =
fn config => Config.iflcLibDirectory config
Expand Down Expand Up @@ -591,6 +590,15 @@ struct
in [file]
end

fun runtimeLibraries (config) =
let
val hrcGhcRtLib =
case Config.targetWordSize config
of Config.Ws32 => "libhrc_ghc_runtime32.a"
| Config.Ws64 => "libhrc_ghc_runtime64.a"
in [hrcGhcRtLib]
end

fun unmanagedLibraries (config) =
let
val threads =
Expand All @@ -606,11 +614,12 @@ struct
val (prtBegin, prtEnd) =
([ifDebug (config, "pillar2c_crt_begind.obj", "pillar2c_crt_begin.obj")],
[ifDebug (config, "pillar2c_crt_endd.obj", "pillar2c_crt_end.obj")])
val gcLibs = gcLibraries (config)
val futureLibs = futureLibraries (config)
val unmanagedLibs = unmanagedLibraries (config)
val gcLibs = gcLibraries config
val futureLibs = futureLibraries config
val runtimeLibs = runtimeLibraries config
val unmanagedLibs = unmanagedLibraries config
val pre = prtBegin
val post = List.concat [futureLibs, prtEnd, gcLibs, unmanagedLibs]
val post = List.concat [futureLibs, prtEnd, gcLibs, runtimeLibs, unmanagedLibs]
in (pre, post)
end

Expand Down
20 changes: 3 additions & 17 deletions compiler/back-end/mil-to-pil.sml
Expand Up @@ -3357,25 +3357,11 @@ struct
Pil.D.blank,
omDefs,
Pil.D.blank,
Pil.D.includeLocalFile "ihc/pil",
Pil.D.includeLocalFile "ihc/plsr",
Pil.D.includeLocalFile "hrc/pil",
Pil.D.includeLocalFile "hrc/plsr",
Pil.D.blank,
incs,
(*
There are a number of reasons we don't want to print externs in the output file:
1. GHC's extern declaration doesn't exactly match C function's type, for example,
CInt is internally represented as Int# in GHC Core, which translates to int64
on x86_64, and if we have already included a C header, it will become a type
mis-match, and GCC will error (ICC will warn).
2. We have already included all header files, which will be inlined by pilicl,
and extern definitions following the header files are just redundant.
Unless we can fix 1, or the assumption in 2 is no longer valid, we can safety
exclude extern declarations in the output.
*)
(* exts, *)
exts,
Pil.D.blank,
Pil.D.comment "Types",
typs,
Expand Down
18 changes: 17 additions & 1 deletion configure.ac
Expand Up @@ -2,11 +2,27 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.60])
AC_INIT([ihc], [0.1], [BUG-REPORT-ADDRESS])
AC_INIT([hrc], [0.1], [BUG-REPORT-ADDRESS])

AC_CHECK_HEADERS([assert.h float.h immintrin.h limits.h locale.h malloc.h math.h nmmintrin.h signal.h stdarg.h stdio.h stdlib.h string.h time.h sys/time.h sys/timeb.h termios.h])

PKG_CHECK_MODULES([IFLC_LIB], [iflc-lib])

PLATFORM_CPPFLAGS=
AC_CANONICAL_HOST
case "$host" in
*-mingw*|*-*-cygwin*)
;;
*-*-linux*)
PLATFORM_CPPFLAGS="-DPLSR_LINUX"
;;
*)
AC_MSG_ERROR([Unsupported host: $host])
;;
esac

AC_SUBST([PLATFORM_CPPFLAGS])

AM_SUBST_NOTMAKE
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

0 comments on commit 60f1837

Please sign in to comment.