... rather than from tccdir. Also allows to load cross versions of bcheck.o etc. (if we would build them which we currently don't). 18 insertions(+), 24 deletions(-)
Unified · Split
| @@ -172,10 +172,10 @@ DEFINES += $(DEF-$(or $(findstring win,$T),unx)) · 171 unmodified lines | |||
| 172 | 172 | ||
| 173 | ifneq ($(X),) | 173 | ifneq ($(X),) |
| 174 | ifeq ($(CONFIG_WIN32),yes) | 174 | ifeq ($(CONFIG_WIN32),yes) |
| 175 | DEF-win += -DTCC_LIBTCC1="\"$(X)libtcc1.a\"" | 175 | DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\"" |
| 176 | DEF-unx += -DTCC_LIBTCC1="\"lib/$(X)libtcc1.a\"" | 176 | DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\"" |
| 177 | else | 177 | else |
| 178 | DEF-all += -DTCC_LIBTCC1="\"$(X)libtcc1.a\"" | 178 | DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\"" |
| 179 | DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" | 179 | DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" |
| 180 | endif | 180 | endif |
| 181 | endif | 181 | endif |
| @@ -1167,14 +1167,24 @@ static int tcc_add_library_internal(TCCState *s, const char *fmt, · 1166 unmodified lines | |||
| 1167 | return -1; | 1167 | return -1; |
| 1168 | } | 1168 | } |
| 1169 | 1169 | ||
| 1170 | #ifndef TCC_TARGET_MACHO | ||
| 1171 | /* find and load a dll. Return non zero if not found */ | 1170 | /* find and load a dll. Return non zero if not found */ |
| 1172 | ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags) | 1171 | ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags) |
| 1173 | { | 1172 | { |
| 1174 | return tcc_add_library_internal(s, "%s/%s", filename, flags, | 1173 | return tcc_add_library_internal(s, "%s/%s", filename, flags, |
| 1175 | s->library_paths, s->nb_library_paths); | 1174 | s->library_paths, s->nb_library_paths); |
| 1176 | } | 1175 | } |
| 1176 | |||
| 1177 | /* find [cross-]libtcc1.a and tcc helper objects in library path */ | ||
| 1178 | ST_FUNC void tcc_add_support(TCCState *s1, const char *filename) | ||
| 1179 | { | ||
| 1180 | #ifdef CONFIG_TCC_CROSSPREFIX | ||
| 1181 | char buf[100]; | ||
| 1182 | snprintf(buf, sizeof buf, "%s%s", CONFIG_TCC_CROSSPREFIX, filename); | ||
| 1183 | filename = buf; | ||
| 1177 | #endif | 1184 | #endif |
| 1185 | if (tcc_add_dll(s1, filename, 0) < 0) | ||
| 1186 | tcc_error_noabort("%s not found", filename); | ||
| 1187 | } | ||
| 1178 | 1188 | ||
| 1179 | #if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO | 1189 | #if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO |
| 1180 | ST_FUNC int tcc_add_crt(TCCState *s1, const char *filename) | 1190 | ST_FUNC int tcc_add_crt(TCCState *s1, const char *filename) |
| @@ -203,8 +203,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 202 unmodified lines | |||
| 203 | # endif | 203 | # endif |
| 204 | #endif | 204 | #endif |
| 205 | 205 | ||
| 206 | #if !defined TCC_IS_NATIVE \ | 206 | #if defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0 |
| 207 | || (defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0) | ||
| 208 | # undef CONFIG_TCC_BACKTRACE | 207 | # undef CONFIG_TCC_BACKTRACE |
| 209 | #else | 208 | #else |
| 210 | # define CONFIG_TCC_BACKTRACE 1 /* enable builtin stack backtraces */ | 209 | # define CONFIG_TCC_BACKTRACE 1 /* enable builtin stack backtraces */ |
| @@ -285,7 +284,8 @@ extern long double strtold (const char *__nptr, char **__endptr); · 74 unmodified lines | |||
| 285 | # define CONFIG_TCC_LIBPATHS "{B}/lib" | 284 | # define CONFIG_TCC_LIBPATHS "{B}/lib" |
| 286 | # else | 285 | # else |
| 287 | # define CONFIG_TCC_LIBPATHS \ | 286 | # define CONFIG_TCC_LIBPATHS \ |
| 288 | ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ | 287 | "{B}" \ |
| 288 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ | ||
| 289 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ | 289 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ |
| 290 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) | 290 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) |
| 291 | # endif | 291 | # endif |
| @@ -1264,9 +1264,8 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 972 unmodified lines | |||
| 1264 | #ifndef ELF_OBJ_ONLY | 1264 | #ifndef ELF_OBJ_ONLY |
| 1265 | ST_FUNC int tcc_add_crt(TCCState *s, const char *filename); | 1265 | ST_FUNC int tcc_add_crt(TCCState *s, const char *filename); |
| 1266 | #endif | 1266 | #endif |
| 1267 | #ifndef TCC_TARGET_MACHO | ||
| 1268 | ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags); | 1267 | ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags); |
| 1269 | #endif | 1268 | ST_FUNC void tcc_add_support(TCCState *s1, const char *filename); |
| 1270 | #ifdef CONFIG_TCC_BCHECK | 1269 | #ifdef CONFIG_TCC_BCHECK |
| 1271 | ST_FUNC void tcc_add_bcheck(TCCState *s1); | 1270 | ST_FUNC void tcc_add_bcheck(TCCState *s1); |
| 1272 | #endif | 1271 | #endif |
| @@ -1299,15 +1299,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 1298 unmodified lines | |||
| 1299 | set_global_sym(s1, buf, s, end_offset); | 1299 | set_global_sym(s1, buf, s, end_offset); |
| 1300 | } | 1300 | } |
| 1301 | 1301 | ||
| 1302 | #ifndef TCC_TARGET_PE | ||
| 1303 | static void tcc_add_support(TCCState *s1, const char *filename) | ||
| 1304 | { | ||
| 1305 | char buf[1024]; | ||
| 1306 | snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename); | ||
| 1307 | tcc_add_file(s1, buf); | ||
| 1308 | } | ||
| 1309 | #endif | ||
| 1310 | |||
| 1311 | ST_FUNC void add_array (TCCState *s1, const char *sec, int c) | 1302 | ST_FUNC void add_array (TCCState *s1, const char *sec, int c) |
| 1312 | { | 1303 | { |
| 1313 | Section *s; | 1304 | Section *s; |
| @@ -1858,12 +1858,6 @@ ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack) · 1857 unmodified lines | |||
| 1858 | #define PE_STDSYM(n,s) "_" n s | 1858 | #define PE_STDSYM(n,s) "_" n s |
| 1859 | #endif | 1859 | #endif |
| 1860 | 1860 | ||
| 1861 | static void tcc_add_support(TCCState *s1, const char *filename) | ||
| 1862 | { | ||
| 1863 | if (tcc_add_dll(s1, filename, 0) < 0) | ||
| 1864 | tcc_error_noabort("%s not found", filename); | ||
| 1865 | } | ||
| 1866 | |||
| 1867 | static void pe_add_runtime(TCCState *s1, struct pe_info *pe) | 1861 | static void pe_add_runtime(TCCState *s1, struct pe_info *pe) |
| 1868 | { | 1862 | { |
| 1869 | const char *start_symbol; | 1863 | const char *start_symbol; |