Skip to content

Commit 721ac4a

Browse files
committed
enable hardware intrinsics for libaom
1 parent 11e19db commit 721ac4a

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/SPC/builder/unix/library/libaom.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use SPC\toolchain\ToolchainManager;
88
use SPC\toolchain\ZigToolchain;
99
use SPC\util\executor\UnixCMakeExecutor;
10+
use SPC\util\SPCTarget;
1011

1112
trait libaom
1213
{
@@ -17,9 +18,16 @@ protected function build(): void
1718
$new = trim($extra . ' -D_GNU_SOURCE');
1819
f_putenv("SPC_COMPILER_EXTRA={$new}");
1920
}
21+
$targetCpu = SPCTarget::getTargetArch();
22+
if (str_starts_with($targetCpu, 'aarch')) {
23+
$targetCpu = str_replace($targetCpu, 'aarch', 'arm');
24+
}
2025
UnixCMakeExecutor::create($this)
2126
->setBuildDir("{$this->source_dir}/builddir")
22-
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
27+
->addConfigureArgs(
28+
"-DAOM_TARGET_CPU={$targetCpu}",
29+
'-DCONFIG_RUNTIME_CPU_DETECT=1'
30+
)
2331
->build();
2432
f_putenv("SPC_COMPILER_EXTRA={$extra}");
2533
$this->patchPkgconfPrefix(['aom.pc']);

src/SPC/util/SPCTarget.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,19 @@ public static function getTargetOS(): string
127127
default => PHP_OS_FAMILY,
128128
};
129129
}
130+
131+
/**
132+
* Returns the target OS arch, e.g. x86_64, aarch64, arm, x86.
133+
*/
134+
public static function getTargetArch(): string
135+
{
136+
$target = (string) getenv('SPC_TARGET');
137+
return match (true) {
138+
str_starts_with($target, 'aarch64') => 'aarch64',
139+
str_starts_with($target, 'arm-') => 'arm',
140+
str_starts_with($target, 'x86_64-') => 'x86_64',
141+
str_starts_with($target, 'x86-') => 'x86',
142+
default => GNU_ARCH,
143+
};
144+
}
130145
}

0 commit comments

Comments
 (0)