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