Skip to content

Commit

Permalink
Merge pull request #361 from MatthewFluet/make-runtime-updates
Browse files Browse the repository at this point in the history
Updates to `make runtime`

Highlights:

* Use proper Makefile rules for `/runtime/gen/sizes`, `/runtime/gen/ml-types.h`,
  `/runtime/gen/c-types.{h,sml}`, and `/runtime/gen/basis-ffi.{h,sml}`, making
  the generator executables a dependency, updating the generator programs to
  emit each file separately (according to program argument), and eliminating the
  use of `.stamp` files (45041d9, 36494b0, ac1651a, 6a37cc3).

* Avoid building `runtime/gen/basis-ffi.{h,sml}` with clean sources (76da64c).

* Use automatic dependencies via `cc -MM` and `.d`-files (eeee00f).

* Add and use `WITH_{DBG,PIC}_RUNTIME` in `runtime/Makefile` (18c6f0c).

* Build with `WITH_DBG_RUNTIME=false` in `./bin/travis-ci` (84d4861).

* Copy `%-pic.a` from `%.a` when PIC enabled by default (a864e2c).

The last two, in particular, allow TravisCI to only build one variant of the
runtime, rather than 3.

The goal had been to bring some order to `runtime/Makefile` and potentially
better understand how to handle non-PI vs PIC vs PIE (see #191).
  • Loading branch information
MatthewFluet authored Jan 18, 2020
2 parents 432866e + 78a857a commit f1316a5
Show file tree
Hide file tree
Showing 35 changed files with 1,376 additions and 540 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (C) 2009,2011,2013,2017-2019 Matthew Fluet.
## Copyright (C) 2009,2011,2013,2017-2020 Matthew Fluet.
# Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
# Jagannathan, and Stephen Weeks.
# Copyright (C) 1997-2000 NEC Research Institute.
Expand All @@ -23,7 +23,7 @@ ifeq (2, $(firstword $(sort $(BOOTSTRAP_STYLE) 2)))
$(MAKE) compiler SELF_COMPILE=true CHECK_FIXPOINT=false # tools1 + mlton1 -> mlton2
ifeq (3, $(firstword $(sort $(BOOTSTRAP_STYLE) 3)))
$(MAKE) tools-clean
$(MAKE) tools CHECK_FIXPOINT=true # tools1 + mlton1 -> tools2; tools2 == tools1
$(MAKE) tools CHECK_FIXPOINT=true # tools1 + mlton2 -> tools2; tools2 == tools1
$(MAKE) compiler-clean
$(MAKE) compiler SELF_COMPILE=true CHECK_FIXPOINT=true # tools2 + mlton2 -> mlton3; mlton3 == mlton2
endif
Expand Down
10 changes: 7 additions & 3 deletions Makefile.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (C) 2009,2011,2013,2017-2019 Matthew Fluet.
## Copyright (C) 2009,2011,2013,2017-2020 Matthew Fluet.
# Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
# Jagannathan, and Stephen Weeks.
# Copyright (C) 1997-2000 NEC Research Institute.
Expand Down Expand Up @@ -58,6 +58,7 @@ GIT := git
GREP := grep
GZIP := gzip
PATCH := patch
SHASUM := shasum
SED := sed
TAR := tar
XARGS := xargs
Expand Down Expand Up @@ -156,16 +157,19 @@ endif

ifeq (0, $(MAKELEVEL))
define CHECK_CMD
ifeq (true, $$(shell ! ($($(2)) >/dev/null 2>&1 || [ $$$$? != 127 ]) && echo true))
ifeq (true, $$(shell if ! [ -x "$$$$(command -v "$($(2))")" ]; then echo true; fi))
$$(warning '$(1)' command not found: $($(2)))
## $(2) := no-$(1)
else
## $(2) := $$(shell command -v "$($(2))")
endif
endef
$(eval $(call CHECK_CMD,mlton,RUN_MLTON))
$(eval $(call CHECK_CMD,mllex,RUN_MLLEX))
$(eval $(call CHECK_CMD,mlyacc,RUN_MLYACC))
endif

RUN_MLTON_VERSION := $(shell "$(RUN_MLTON)" | $(SED) -En 's/MLton.*([0-9]{8}).*/\1/p')
RUN_MLTON_VERSION := $(shell command -v "$(RUN_MLTON)" >/dev/null 2>&1 && "$(RUN_MLTON)" | $(SED) -En 's/MLton.*([0-9]{8}).*/\1/p' || echo "????????")

######################################################################

Expand Down
2 changes: 1 addition & 1 deletion bin/travis-ci
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
MLTON_RUNTIME_ARGS="ram-slop 0.90"

echo "Building MLton..."
make CC="$CC" OLD_MLTON_RUNTIME_ARGS="$MLTON_RUNTIME_ARGS" MLTON_RUNTIME_ARGS="$MLTON_RUNTIME_ARGS" MLTON_COMPILE_ARGS="$MLTON_COMPILE_ARGS" all
make CC="$CC" OLD_MLTON_RUNTIME_ARGS="$MLTON_RUNTIME_ARGS" MLTON_RUNTIME_ARGS="$MLTON_RUNTIME_ARGS" MLTON_COMPILE_ARGS="$MLTON_COMPILE_ARGS" WITH_DBG_RUNTIME=false all

if [ "$REGRESSION" == "true" ]; then
echo "Running regression tests..."
Expand Down
27 changes: 12 additions & 15 deletions mlton/main/main.fun
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,13 @@ fun commandLine (args: string list): unit =
| Self => !cc
val arScript = !arScript

local
fun mk (b, suf) s =
if b then s ^ "-" ^ suf else s
in
val addDBG = mk (!debugRuntime, "dbg")
val addPIC = mk (positionIndependent, "pic")
end
fun addTargetOpts opts =
List.fold
(!opts, [], fn ({opt, pred}, ac) =>
Expand All @@ -1139,24 +1146,14 @@ fun commandLine (args: string list): unit =
val asOpts = addTargetOpts asOpts
val ccOpts = addTargetOpts ccOpts
val linkOpts = addTargetOpts linkOpts
val linkOpts = if !debugRuntime then
"-lmlton-gdb" :: "-lgdtoa-gdb" :: linkOpts
else if positionIndependent then
"-lmlton-pic" :: "-lgdtoa-pic" :: linkOpts
else
"-lmlton" :: "-lgdtoa" :: linkOpts
val linkOpts =
List.map (["mlton", "gdtoa"], fn lib => "-l" ^ addPIC (addDBG lib)) @ linkOpts
val linkOpts = ("-L" ^ targetLibDir) :: linkOpts

val linkArchives =
if !debugRuntime then
[OS.Path.joinDirFile {dir = targetLibDir, file = "libmlton-gdb.a"},
OS.Path.joinDirFile {dir = targetLibDir, file = "libgdtoa-gdb.a"}]
else if positionIndependent then
[OS.Path.joinDirFile {dir = targetLibDir, file = "libmlton-pic.a"},
OS.Path.joinDirFile {dir = targetLibDir, file = "libgdtoa-pic.a"}]
else
[OS.Path.joinDirFile {dir = targetLibDir, file = "libmlton.a"},
OS.Path.joinDirFile {dir = targetLibDir, file = "libgdtoa.a"}]
List.map (["mlton", "gdtoa"], fn lib =>
OS.Path.joinDirFile {dir = targetLibDir,
file = "lib" ^ addPIC (addDBG lib) ^ ".a"})

val llvm_as = !llvm_as
val llvm_llc = !llvm_llc
Expand Down
3 changes: 2 additions & 1 deletion runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Ignore all *.a and *.o files
## Ignore all *.a, *.d, and *.o files
*.a
*.d
*.o

/gdtoa/
Expand Down
Loading

0 comments on commit f1316a5

Please sign in to comment.