From 8e493d1dcb8b6bb65abe79ab440fb82626a3cbff Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 26 Feb 2018 13:16:38 +1030 Subject: [PATCH 1/3] ccan: update so we get configurator with --configurator-cc= arg. Signed-off-by: Rusty Russell --- ccan/README | 2 +- ccan/tools/configurator/configurator.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ccan/README b/ccan/README index 91800fde4f2b..7fa333ec8774 100644 --- a/ccan/README +++ b/ccan/README @@ -1,3 +1,3 @@ CCAN imported from http://ccodearchive.net. -CCAN version: init-2402-gec1f7161 +CCAN version: init-2403-g8502a66a diff --git a/ccan/tools/configurator/configurator.c b/ccan/tools/configurator/configurator.c index 52c0243b4b99..ff9f64904bb0 100644 --- a/ccan/tools/configurator/configurator.c +++ b/ccan/tools/configurator/configurator.c @@ -670,13 +670,15 @@ int main(int argc, const char *argv[]) const char *default_args[] = { "", DEFAULT_COMPILER, DEFAULT_FLAGS, NULL }; const char *outflag = DEFAULT_OUTPUT_EXE_FLAG; + const char *configurator_cc = NULL; + const char *orig_cc; if (argc > 0) progname = argv[0]; while (argc > 1) { if (strcmp(argv[1], "--help") == 0) { - printf("Usage: configurator [-v] [-O] [ ...]\n" + printf("Usage: configurator [-v] [-O] [--configurator-cc=] [ ...]\n" " will have \" \" appended\n" "Default: %s %s %s\n", DEFAULT_COMPILER, DEFAULT_FLAGS, @@ -701,6 +703,10 @@ int main(int argc, const char *argv[]) argc--; argv++; verbose += 2; + } else if (strncmp(argv[1], "--configurator-cc=", 18) == 0) { + configurator_cc = argv[1] + 18; + argc--; + argv++; } else { break; } @@ -709,6 +715,10 @@ int main(int argc, const char *argv[]) if (argc == 1) argv = default_args; + orig_cc = argv[1]; + if (configurator_cc) + argv[1] = configurator_cc; + cmd = connect_args(argv, outflag, OUTPUT_FILE " " INPUT_FILE); for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) run_test(cmd, &tests[i]); @@ -723,7 +733,7 @@ int main(int argc, const char *argv[]) printf("#ifndef _GNU_SOURCE\n"); printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n"); printf("#endif\n"); - printf("#define CCAN_COMPILER \"%s\"\n", argv[1]); + printf("#define CCAN_COMPILER \"%s\"\n", orig_cc); cmd = connect_args(argv + 1, "", ""); printf("#define CCAN_CFLAGS \"%s\"\n", cmd); free(cmd); From c51cb8579bd23b9fbbcd2cdcbfc5de194e0d30ac Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 26 Feb 2018 13:21:55 +1030 Subject: [PATCH 2/3] Makefile: allow configurator to use a different CC, by setting CONFIGURATOR_CC This should solve what @icota wanted in https://github.com/ElementsProject/lightning/pull/1035 in a much cleaner way. In particular, this allows you to say what configurator should use, independent of what other compilation should use, and reverts the '-static' which broke MacOS. Fixes: #1059 Signed-off-by: Rusty Russell --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e16e956cc6f6..91be5f4d2e01 100644 --- a/Makefile +++ b/Makefile @@ -163,6 +163,9 @@ CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations CDEBUGFLAGS := -std=gnu11 -g -fstack-protector CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) +# We can get configurator to run a different compile cmd to cross-configure. +CONFIGURATOR_CC := $(CC) + LDFLAGS = $(PIE_LDFLAGS) LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 $(COVFLAGS) @@ -264,7 +267,7 @@ ALL_PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS) Makefile ccan/config.h: ccan/tools/configurator/configurator - if $< $(CC) -static > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi + if $< --configurator-cc="$(CONFIGURATOR_CC)" $(CC) $(CFLAGS) > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi gen_version.h: FORCE @(echo "#define VERSION \"`git describe --always --dirty`\"" && echo "#define VERSION_NAME \"$(NAME)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new From e9a35f5b866765c5d3e350d9ce672d2ebabe0043 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 26 Feb 2018 13:23:01 +1030 Subject: [PATCH 3/3] ccan/config.h: make it depend on the top-level Makefile. This way if the argument change, it will be regenerated. Signed-off-by: Rusty Russell --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 91be5f4d2e01..3f5f333dabb9 100644 --- a/Makefile +++ b/Makefile @@ -266,7 +266,7 @@ ALL_PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr # Can't add to ALL_OBJS, as that makes a circular dep. ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS) Makefile -ccan/config.h: ccan/tools/configurator/configurator +ccan/config.h: ccan/tools/configurator/configurator Makefile if $< --configurator-cc="$(CONFIGURATOR_CC)" $(CC) $(CFLAGS) > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi gen_version.h: FORCE