Using uname in tccelf.c was not working when cross compiling. So move it to configure script.
Unified · Split
| @@ -27,6 +27,7 @@ mandir="" · 26 unmodified lines | ||
| 27 | 27 | infodir="" |
| 28 | 28 | sysroot="" |
| 29 | 29 | cross_prefix="" |
| 30 | +os_release="" | |
| 30 | 31 | cc="gcc" |
| 31 | 32 | ar="ar" |
| 32 | 33 | bigendian="no" |
| @@ -123,6 +124,8 @@ for opt do · 90 unmodified lines | ||
| 123 | 124 | ;; |
| 124 | 125 | --cross-prefix=*) assign_opt "$opt" cross_prefix |
| 125 | 126 | ;; |
| 127 | + --os-release=*) assign_opt "$opt" os_release | |
| 128 | + ;; | |
| 126 | 129 | --cc=*) assign_opt "$opt" |
| 127 | 130 | ;; |
| 128 | 131 | --ar=*) assign_opt "$opt" ; ar_set="yes" |
| @@ -232,6 +235,7 @@ Cross build options (experimental): · 103 unmodified lines | ||
| 232 | 235 | --cpu=CPU target CPU [$cpu] |
| 233 | 236 | --targetos=... target OS (Darwin,WIN32,Android/Termux) [$targetos] |
| 234 | 237 | --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] |
| 238 | + --os-release=x.y.z use os release x.y.z [$os_release] | |
| 235 | 239 | EOF |
| 236 | 240 | exit 1 |
| 237 | 241 | } |
| @@ -290,6 +294,11 @@ then · 52 unmodified lines | ||
| 290 | 294 | ar="${cross_prefix}${ar}" |
| 291 | 295 | fi |
| 292 | 296 | |
| 297 | +if test -z "$os_release" | |
| 298 | +then | |
| 299 | + os_release=$(uname -r) | |
| 300 | +fi | |
| 301 | + | |
| 293 | 302 | case "$cpu" in |
| 294 | 303 | x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386) |
| 295 | 304 | cpu="i386" |
| @@ -704,6 +713,7 @@ print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp" · 408 unmodified lines | ||
| 704 | 713 | print_str CONFIG_TCC_SWITCHES "$tcc_switches" |
| 705 | 714 | print_str CONFIG_LDDIR "$tcc_lddir" |
| 706 | 715 | print_str CONFIG_TRIPLET "$triplet" |
| 716 | +print_str CONFIG_OS_RELEASE "$os_release" | |
| 707 | 717 | echo "#endif" >> $TMPH && echo >> $TMPH |
| 708 | 718 | |
| 709 | 719 | print_str CONFIG_SYSROOT "$sysroot" x |
| @@ -2804,9 +2804,6 @@ static void create_arm_attribute_section(TCCState *s1) · 2803 unmodified lines | ||
| 2804 | 2804 | #endif |
| 2805 | 2805 | |
| 2806 | 2806 | #if TARGETOS_OpenBSD || TARGETOS_NetBSD || TARGETOS_FreeBSD |
| 2807 | −#ifndef _WIN32 | |
| 2808 | −#include <sys/utsname.h> | |
| 2809 | −#endif | |
| 2810 | 2807 | |
| 2811 | 2808 | static void fill_bsd_note(Section *s, int type, |
| 2812 | 2809 | const char *value, uint32_t data) |
| @@ -2839,12 +2836,9 @@ static Section *create_bsd_note_section(TCCState *s1, · 26 unmodified lines | ||
| 2839 | 2836 | { |
| 2840 | 2837 | Section *s; |
| 2841 | 2838 | unsigned int major = 0, minor = 0, patch = 0; |
| 2842 | −#ifndef _WIN32 | |
| 2843 | − struct utsname uts; | |
| 2844 | 2839 | |
| 2845 | −/* Maybe move this to configure option for cross compiling */ | |
| 2846 | − if (!uname(&uts)) | |
| 2847 | − sscanf(uts.release, "%u.%u.%u", &major, &minor, &patch); | |
| 2840 | +#ifdef CONFIG_OS_RELEASE | |
| 2841 | + sscanf(CONFIG_OS_RELEASE, "%u.%u.%u", &major, &minor, &patch); | |
| 2848 | 2842 | #endif |
| 2849 | 2843 | #if TARGETOS_FreeBSD |
| 2850 | 2844 | if (major < 14) |