Use configure to set note release bsd

Using uname in tccelf.c was not working when cross compiling.
So move it to configure script.
This commit is contained in:
herman ten brugge
2025-09-04 06:47:40 +02:00
parent 8c3396a76f
commit 03072a301c
2 changed files with 12 additions and 8 deletions

10
configure vendored
View File

@@ -27,6 +27,7 @@ mandir=""
infodir=""
sysroot=""
cross_prefix=""
os_release=""
cc="gcc"
ar="ar"
bigendian="no"
@@ -123,6 +124,8 @@ for opt do
;;
--cross-prefix=*) assign_opt "$opt" cross_prefix
;;
--os-release=*) assign_opt "$opt" os_release
;;
--cc=*) assign_opt "$opt"
;;
--ar=*) assign_opt "$opt" ; ar_set="yes"
@@ -232,6 +235,7 @@ Cross build options (experimental):
--cpu=CPU target CPU [$cpu]
--targetos=... target OS (Darwin,WIN32,Android/Termux) [$targetos]
--cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
--os-release=x.y.z use os release x.y.z [$os_release]
EOF
exit 1
}
@@ -290,6 +294,11 @@ then
ar="${cross_prefix}${ar}"
fi
if test -z "$os_release"
then
os_release=$(uname -r)
fi
case "$cpu" in
x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386)
cpu="i386"
@@ -704,6 +713,7 @@ print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
print_str CONFIG_TCC_SWITCHES "$tcc_switches"
print_str CONFIG_LDDIR "$tcc_lddir"
print_str CONFIG_TRIPLET "$triplet"
print_str CONFIG_OS_RELEASE "$os_release"
echo "#endif" >> $TMPH && echo >> $TMPH
print_str CONFIG_SYSROOT "$sysroot" x

View File

@@ -2804,9 +2804,6 @@ static void create_arm_attribute_section(TCCState *s1)
#endif
#if TARGETOS_OpenBSD || TARGETOS_NetBSD || TARGETOS_FreeBSD
#ifndef _WIN32
#include <sys/utsname.h>
#endif
static void fill_bsd_note(Section *s, int type,
const char *value, uint32_t data)
@@ -2839,12 +2836,9 @@ static Section *create_bsd_note_section(TCCState *s1,
{
Section *s;
unsigned int major = 0, minor = 0, patch = 0;
#ifndef _WIN32
struct utsname uts;
/* Maybe move this to configure option for cross compiling */
if (!uname(&uts))
sscanf(uts.release, "%u.%u.%u", &major, &minor, &patch);
#ifdef CONFIG_OS_RELEASE
sscanf(CONFIG_OS_RELEASE, "%u.%u.%u", &major, &minor, &patch);
#endif
#if TARGETOS_FreeBSD
if (major < 14)