mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
change macOS to not use "-dead_strip_dylibs" when CUSTOM is defined
Under macOS, to reduce dependency chains, we remove functions and data that are unreachable by the entry point or exported symbols. In particular, the macOS linker is used with "-dead_strip". While calc on macOS will execute if linker used with "-dead_strip_dylibs" and CUSTOM is defined, other applications that use libcalc but not libcustcalc (such as sample_many and sample_rand) will fail to execute due to missile symbols. Therefore "-dead_strip_dylibs" is not used by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
This commit is contained in:
9
CHANGES
9
CHANGES
@@ -92,8 +92,13 @@ 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" and with
|
||||
"-dead_strip_dylibs".
|
||||
In particular, the macOS linker is used with "-dead_strip".
|
||||
|
||||
While calc on macOS will execute if linker used with "-dead_strip_dylibs"
|
||||
and CUSTOM is defined, other applications that use libcalc but not
|
||||
libcustcalc (such as sample_many and sample_rand) will fail to execute
|
||||
due to missile symbols. Therefore "-dead_strip_dylibs" is not used
|
||||
by default when ALLOW_CUSTOM is "-DCUSTOM" under macOS.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.14.2.1 to 2.14.3.0:
|
||||
|
@@ -177,7 +177,22 @@ LIBCUSTCALC_SHLIB= -dynamiclib -undefined dynamic_lookup \
|
||||
# data that are unreachable by the entry point or exported symbols.
|
||||
#
|
||||
COMMON_LDFLAGS+= -Wl,-dead_strip
|
||||
|
||||
# Do not link with "-dead_strip_dylibs" if CUSTOM is defined
|
||||
# (i.e., ${ALLOW_CUSTOM} is "-DCUSTOM). This is because unless
|
||||
# the application makes an explicit symbol reference to some symbol
|
||||
# in libcustcalc, the application will fail to execute due to
|
||||
# a missing symbol.
|
||||
#
|
||||
# The calc application will run with CUSTOM defined under
|
||||
# "-dead_strip_dylibs" because calc.o (in main()) makes an explicit
|
||||
# reference to custtbl_allowed (see custom/custtbl.c) in libcustcalc.
|
||||
# However applications such as sample_many and sample_rand will
|
||||
# fail to load when CUSTOM is defined and "-dead_strip_dylibs" is used..
|
||||
#
|
||||
ifneq ($(ALLOW_CUSTOM),-DCUSTOM)
|
||||
COMMON_LDFLAGS+= -Wl,-dead_strip_dylibs
|
||||
endif # ($(ALLOW_CUSTOM),-DCUSTOM)
|
||||
|
||||
# static library option
|
||||
#
|
||||
|
10
calc.c
10
calc.c
@@ -166,6 +166,11 @@ main(int argc, char **argv)
|
||||
#if defined(CUSTOM)
|
||||
/*
|
||||
* validate custtbl_allowed value
|
||||
*
|
||||
* We make an explicit reference to the custtbl_allowed symbol
|
||||
* in libcustcalc (see custom/custtbl.c) so that the use
|
||||
* of "-dead_strip_dylibs" with the macOS linker won't cause
|
||||
* the calc to fail to load due to a missing symbol.
|
||||
*/
|
||||
if (custtbl_allowed == 0) {
|
||||
fprintf(stderr, "%s: calc was built with "
|
||||
@@ -183,6 +188,11 @@ main(int argc, char **argv)
|
||||
#else /* CUSTOM */
|
||||
/*
|
||||
* validate custtbl_allowed value
|
||||
*
|
||||
* We make an explicit reference to the custtbl_allowed symbol
|
||||
* in libcustcalc (see custom/custtbl.c) so that the use
|
||||
* of "-dead_strip_dylibs" with the macOS linker won't cause
|
||||
* the calc to fail to load due to a missing symbol.
|
||||
*/
|
||||
if (custtbl_allowed != 0) {
|
||||
fprintf(stderr, "%s: calc was built with "
|
||||
|
21
custom.c
21
custom.c
@@ -41,6 +41,8 @@
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
EXTERN CONST struct custom cust[]; /* custom interface table */
|
||||
|
||||
#else /* CUSTOM */
|
||||
|
||||
#include "config.h"
|
||||
@@ -91,16 +93,6 @@ custom(char *name, int count, VALUE **vals)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* validate custtbl_allowed value
|
||||
*/
|
||||
if (custtbl_allowed == 0) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
}
|
||||
|
||||
/*
|
||||
* no such custom function
|
||||
*/
|
||||
@@ -117,15 +109,6 @@ custom(char *name, int count, VALUE **vals)
|
||||
(conf->tab_ok ? "\t" : ""), name, count,
|
||||
(vals == NULL) ? "NULL" : "non-NULL");
|
||||
}
|
||||
|
||||
/*
|
||||
* validate custtbl_allowed value
|
||||
*/
|
||||
if (custtbl_allowed != 0) {
|
||||
fprintf(stderr,
|
||||
"%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);
|
||||
|
||||
#endif /* CUSTOM */
|
||||
|
3
custom.h
3
custom.h
@@ -78,9 +78,6 @@ E_FUNC VALUE custom(char*, int, VALUE**); /* master custom interface */
|
||||
EXTERN BOOL allow_custom; /* TRUE => custom builtins allowed */
|
||||
E_FUNC void showcustom(void); /* print custom functions */
|
||||
E_FUNC void customhelp(char *); /* direct custom help */
|
||||
#if defined(CUSTOM)
|
||||
EXTERN CONST struct custom cust[]; /* custom interface table */
|
||||
#endif /* CUSTOM */
|
||||
E_FUNC void init_custreg(void); /* initialize custom registers */
|
||||
|
||||
#endif /* !CUSTOM_H */
|
||||
|
Reference in New Issue
Block a user