Commit 9fc2d777 authored by thomie's avatar thomie
Browse files

Build system: don't add ALL_HC_OPTS when linking

Summary:
The current scheme in rules/distdir-way-opts.mk is something like this:
  GHC_LD_OPTS      = MOST_HC_OPTS + ALL_LD_OPTS
  MOST_DIR_HC_OPTS = MOST_HC_OPTS + -odir,-hidir,-stubdir
  ALL_HC_OPTS      = MOST_DIR_HC_OPTS +
                        -hisuf,-osuf,-hcsuf,-split-objs,-dynamic-too

Notice that both ALL_HC_OPTS and GHC_LD_OPTS include MOST_HC_OPTS, and
currently both got added when linking. Adding MOST_HC_OPTS twice results
in overly long and hard to decipher command lines (and build logs). This
commit fixes that.

Afaik, -odir,-hidir,-stubdir,-hisuf,-osuf,-hcsuf,-spit-objs,-dynamic-too
are all not needed when linking, so this change should be safe to make.
GHC_LD_OPTS is for linking, ALL_HC_OPTS is for compiling.

ALL_HC_OPTS was added to the linking commands in
37a6a52f, to make sure
-no-user-package-conf would be in the options list. It still is after
this change.

Reviewers: austin, bgamari

Differential Revision: https://phabricator.haskell.org/D1379
parent d1ab6fc9
......@@ -91,7 +91,7 @@ endif
else # ifneq "$$(HostOS_CPP)" "mingw32"
$$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
$$(call cmd,$1_$2_HC) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
-shared -dynamic -dynload deploy \
$$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)) \
-no-auto-link-packages \
......@@ -170,7 +170,7 @@ endef # build-package-way
# $5 = object files to link
# $6 = output filename
define build-dll
$(call cmd,$1_$2_HC) $($1_$2_$3_ALL_HC_OPTS) $($1_$2_$3_GHC_LD_OPTS) $4 $5 \
$(call cmd,$1_$2_HC) $($1_$2_$3_GHC_LD_OPTS) $4 $5 \
-shared -dynamic -dynload deploy \
$(addprefix -l,$($1_$2_EXTRA_LIBRARIES)) \
-no-auto-link-packages \
......
......@@ -255,7 +255,7 @@ $1/$2/build/tmp/$$($1_$2_PROG).dll : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$(
else # $1_$2_PROG_NEEDS_C_WRAPPER=NO
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
else
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
......
......@@ -131,7 +131,7 @@ $1_$2_$3_MOST_DIR_HC_OPTS = \
# that -O0 is effective (see #5484)
# $1_$2_$3_ALL_HC_OPTS: this is all the options we will pass to GHC
# for a given ($1,$2,$3).
# for a given ($1,$2,$3) when we use it for compiling.
$1_$2_$3_ALL_HC_OPTS = \
-hisuf $$($3_hisuf) -osuf $$($3_osuf) -hcsuf $$($3_hcsuf) \
$$($1_$2_$3_MOST_DIR_HC_OPTS) \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment