some abi fixes for fpc

This commit is contained in:
2026-01-09 17:37:04 +02:00
parent 5ff4521228
commit 64459718b0
4 changed files with 79 additions and 30 deletions

View File

@@ -11,6 +11,14 @@ CUtlString Target_t::GetTriplet()
if ( cpu == TARGET_CPU_AMD64 )
triplet.AppendTail("x86_64");
if ( cpu == TARGET_CPU_80386 )
triplet.AppendTail("i386");
if ( cpu == TARGET_CPU_80486 )
triplet.AppendTail("i486");
if ( cpu == TARGET_CPU_80586 )
triplet.AppendTail("i586");
if ( cpu == TARGET_CPU_80686 )
triplet.AppendTail("i686");
if ( cpu == TARGET_CPU_AARCH64 )
triplet.AppendTail("aarch64");
if ( cpu == TARGET_CPU_WASM32 )
@@ -19,11 +27,9 @@ CUtlString Target_t::GetTriplet()
if ( kernel == TARGET_KERNEL_UNKNOWN )
triplet.AppendTail("unknown-unknown");
if ( kernel == TARGET_KERNEL_LINUX )
triplet.AppendTail("unknown-linux-gnu");
if ( kernel == TARGET_KERNEL_WINDOWS_GNU )
triplet.AppendTail("pc-windows-gnu");
if ( kernel == TARGET_KERNEL_WINDOWS_MSVC )
triplet.AppendTail("pc-windows-msvc");
triplet.AppendTail("unknown-linux");
if ( kernel == TARGET_KERNEL_WINDOWS )
triplet.AppendTail("pc-windows");
if ( kernel == TARGET_KERNEL_DARWIN )
triplet.AppendTail("apple-darwin");
if ( kernel == TARGET_KERNEL_IOS )
@@ -34,6 +40,12 @@ CUtlString Target_t::GetTriplet()
triplet.AppendTail("unknown-wasi");
if ( kernel == TARGET_KERNEL_EMSCRIPTEN )
triplet.AppendTail("unknown-emscripten");
if ( abi != TARGET_ABI_DEFAULT )
triplet.AppendTail("-");
if ( abi == TARGET_ABI_GNU )
triplet.AppendTail("gnu");
if ( abi == TARGET_ABI_MUSL )
triplet.AppendTail("musl");
return triplet;
@@ -49,8 +61,7 @@ const char *Target_t::GetExecutableFileFormat()
case TARGET_KERNEL_IOS:
return "%s";
break;
case TARGET_KERNEL_WINDOWS_MSVC:
case TARGET_KERNEL_WINDOWS_GNU:
case TARGET_KERNEL_WINDOWS:
return "%s.exe";
default:
break;
@@ -66,10 +77,18 @@ const char *Target_t::GetStaticLibraryFileFormat()
case TARGET_KERNEL_ANDROID:
case TARGET_KERNEL_DARWIN:
case TARGET_KERNEL_IOS:
case TARGET_KERNEL_WINDOWS_GNU:
return "lib%s.a";
case TARGET_KERNEL_WINDOWS_MSVC:
return "%s.lib";
return "lib%s.a";
case TARGET_KERNEL_WINDOWS:
{
switch(abi)
{
case TARGET_ABI_MSVC:
return "%s.lib";
default:
return "lib%s.a";
}
}
default:
break;
}
@@ -84,7 +103,7 @@ const char *Target_t::GetDynamicLibraryFileFormat()
return "lib%s.so";
case TARGET_KERNEL_DARWIN:
return "lib%s.dylib";
case TARGET_KERNEL_WINDOWS_GNU:
case TARGET_KERNEL_WINDOWS:
return "%s.dll";
default:
break;
@@ -98,12 +117,36 @@ Target_t Target_t::HostTarget()
{
ETargetKernel kernel =
#if defined(__linux__)
TARGET_KERNEL_LINUX
TARGET_KERNEL_LINUX
#elif defined(__APPLE__)
TARGET_KERNEL_DARWIN
#endif
;
ETargetCPU cpu = TARGET_CPU_AMD64;
ETargetABI abi =
#if defined(__GLIBC__)
#endif
TARGET_ABI_GNU
#if defined(__MUSL__)
TARGET_ABI_MUSL
#endif
;
ETargetCPU cpu =
#if defined(__x86_64__)
TARGET_CPU_AMD64
#endif
#if defined(__i386__)
TARGET_CPU_80386
#endif
#if defined(__i486__)
TARGET_CPU_80486
#endif
#if defined(__i586__)
TARGET_CPU_80586
#endif
#if defined(__i686__)
TARGET_CPU_80686
#endif
;
return {
.kernel = kernel,
.cpu = cpu,
@@ -119,9 +162,11 @@ Target_t Target_t::DefaultTarget()
CUtlString szDevice = CommandLine()->ParamValue("-device");
CUtlString szOS = CommandLine()->ParamValue("-os");
CUtlString szArch = CommandLine()->ParamValue("-arch");
CUtlString szAbi = CommandLine()->ParamValue("-abi");
ETargetKernel kernel = HostTarget().kernel;
ETargetCPU cpu = HostTarget().cpu;
ETargetABI abi = HostTarget().abi;
if ( szArch == "x86_64" )
cpu = TARGET_CPU_AMD64;
@@ -134,8 +179,6 @@ Target_t Target_t::DefaultTarget()
kernel = TARGET_KERNEL_UNKNOWN;
else if ( szOS == "windows" )
kernel = TARGET_KERNEL_WINDOWS;
else if ( szOS == "windows-msvc" )
kernel = TARGET_KERNEL_WINDOWS_MSVC;
else if ( szOS == "linux" )
kernel = TARGET_KERNEL_LINUX;
else if ( szOS == "macos" )
@@ -150,6 +193,7 @@ Target_t Target_t::DefaultTarget()
return {
.kernel = kernel,
.cpu = cpu,
.abi = abi,
.optimization = TARGET_DEBUG,
};
}

View File

@@ -122,9 +122,9 @@ CUtlString CMSVCLinker::Link( LinkProject_t *pProject )
Plat_FatalErrorFunc("m_szName must be present\n");
}
if (pProject->m_target.kernel != TARGET_KERNEL_WINDOWS_MSVC)
if (pProject->m_target.kernel != TARGET_KERNEL_WINDOWS)
{
Plat_FatalErrorFunc("target must be TARGET_KERNEL_WINDOWS_MSVC\n");
Plat_FatalErrorFunc("target must be TARGET_KERNEL_WINDOWS\n");
}
// Find a name for the file