diff --git a/CHANGES b/CHANGES index 0d5f243..ec3db01 100644 --- a/CHANGES +++ b/CHANGES @@ -89,7 +89,8 @@ The following are the changes from calc version 2.14.3.1 to date: Under macOS, to reduce dependency chains, we remove functions and data that are unreachable by the entry point or exported symbols. - In particular, the linker is run with "-dead_strip". + In particular, the linker is run with "-dead_strip" and with + "-dead_strip_dylibs". The following are the changes from calc version 2.14.2.1 to 2.14.3.0: diff --git a/Makefile.target b/Makefile.target index ee91216..7b188e6 100644 --- a/Makefile.target +++ b/Makefile.target @@ -177,13 +177,7 @@ LIBCUSTCALC_SHLIB= -dynamiclib -undefined dynamic_lookup \ # data that are unreachable by the entry point or exported symbols. # COMMON_LDFLAGS+= -Wl,-dead_strip - -# We cannot use: COMMON_LDFLAGS+= -Wl,-dead_strip_dylibs -# -# The macOS ld documentation states that option should not be used -# when linking against a dylib which is required at runtime for some -# indirect reason such as the dylib has an important initializer. -# The libcustcalc appears to have such an initializer. +COMMON_LDFLAGS+= -Wl,-dead_strip_dylibs # static library option # diff --git a/calc.c b/calc.c index cb42dee..a483dd6 100644 --- a/calc.c +++ b/calc.c @@ -164,9 +164,33 @@ main(int argc, char **argv) switch (c) { case 'C': #if defined(CUSTOM) + /* + * validate custtbl_allowed value + */ + if (custtbl_allowed == 0) { + fprintf(stderr, "%s: calc was built with " + "custom functions enabled, " + "but custtbl_allowed: %d == 0\n", + program, custtbl_allowed); + exit(1); + } + + /* + * indicate that custom functions are now allowed + */ allow_custom = TRUE; break; #else /* CUSTOM */ + /* + * validate custtbl_allowed value + */ + if (custtbl_allowed != 0) { + fprintf(stderr, "%s: calc was built with " + "custom functions disabled, " + "but custtbl_allowed: %d != 0\n", + program, custtbl_allowed); + } + /* * we are too early in processing to * call libcalc_call_me_last() - diff --git a/custom.c b/custom.c index 6e0e9db..a0e895b 100644 --- a/custom.c +++ b/custom.c @@ -96,8 +96,8 @@ custom(char *name, int count, VALUE **vals) */ if (custtbl_allowed == 0) { fprintf(stderr, - "%sCalc was built with custom functions enabled but custtbl_allowed is 0\n", - (conf->tab_ok ? "\t" : "")); + "%sCalc was built with custom functions enabled but custtbl_allowed: %d == 0\n", + (conf->tab_ok ? "\t" : ""), custtbl_allowed); return error_value(E_NO_CUSTOM); } @@ -123,8 +123,8 @@ custom(char *name, int count, VALUE **vals) */ if (custtbl_allowed != 0) { fprintf(stderr, - "%sCalc was built with custom functions disabled but custtbl_allowed is != 0\n", - (conf->tab_ok ? "\t" : "")); + "%sCalc was built with custom functions disabled but custtbl_allowed: %d != 0\n", + (conf->tab_ok ? "\t" : ""), custtbl_allowed); } return error_value(E_NO_CUSTOM);