fix use of -dead_strip_dylibs for macOS linker

This commit is contained in:
Landon Curt Noll
2023-08-14 14:58:22 -07:00
parent 92c8d89ed1
commit 40f8654aa4
4 changed files with 31 additions and 12 deletions

View File

@@ -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 Under macOS, to reduce dependency chains, we remove functions and
data that are unreachable by the entry point or exported symbols. 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: The following are the changes from calc version 2.14.2.1 to 2.14.3.0:

View File

@@ -177,13 +177,7 @@ LIBCUSTCALC_SHLIB= -dynamiclib -undefined dynamic_lookup \
# data that are unreachable by the entry point or exported symbols. # data that are unreachable by the entry point or exported symbols.
# #
COMMON_LDFLAGS+= -Wl,-dead_strip COMMON_LDFLAGS+= -Wl,-dead_strip
COMMON_LDFLAGS+= -Wl,-dead_strip_dylibs
# 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.
# static library option # static library option
# #

24
calc.c
View File

@@ -164,9 +164,33 @@ main(int argc, char **argv)
switch (c) { switch (c) {
case 'C': case 'C':
#if defined(CUSTOM) #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; allow_custom = TRUE;
break; break;
#else /* CUSTOM */ #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 * we are too early in processing to
* call libcalc_call_me_last() - * call libcalc_call_me_last() -

View File

@@ -96,8 +96,8 @@ custom(char *name, int count, VALUE **vals)
*/ */
if (custtbl_allowed == 0) { if (custtbl_allowed == 0) {
fprintf(stderr, fprintf(stderr,
"%sCalc was built with custom functions enabled but custtbl_allowed is 0\n", "%sCalc was built with custom functions enabled but custtbl_allowed: %d == 0\n",
(conf->tab_ok ? "\t" : "")); (conf->tab_ok ? "\t" : ""), custtbl_allowed);
return error_value(E_NO_CUSTOM); return error_value(E_NO_CUSTOM);
} }
@@ -123,8 +123,8 @@ custom(char *name, int count, VALUE **vals)
*/ */
if (custtbl_allowed != 0) { if (custtbl_allowed != 0) {
fprintf(stderr, fprintf(stderr,
"%sCalc was built with custom functions disabled but custtbl_allowed is != 0\n", "%sCalc was built with custom functions disabled but custtbl_allowed: %d != 0\n",
(conf->tab_ok ? "\t" : "")); (conf->tab_ok ? "\t" : ""), custtbl_allowed);
} }
return error_value(E_NO_CUSTOM); return error_value(E_NO_CUSTOM);