Skip to content

Commit 96b472e

Browse files
committed
fix(x264): enable assembly on macOS arm64 by using clang as assembler
x264's aarch64 .S files contain macros (T(), const, endconst) requiring C preprocessor expansion. The bare 'as' command skips preprocessing, causing build failures. Setting AS=clang ensures preprocessing runs before assembly, matching Apple's Xcode toolchain behaviour. Removes the --disable-asm workaround that caused 10-20% performance loss. Signed-off-by: Martin Wimpress <martin@wimpress.org>
1 parent a9f99ec commit 96b472e

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

internal/builder/libraries.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ var x264 = &Library{
537537
BuildSystem: &AutoconfBuild{},
538538
SkipAutoFlags: true, // x264 has a custom configure script that rejects CFLAGS/LDFLAGS
539539
ConfigureArgs: func(os string) []string {
540-
args := []string{
540+
return []string{
541541
"--disable-avs",
542542
"--disable-cli",
543543
"--disable-ffms",
@@ -548,18 +548,18 @@ var x264 = &Library{
548548
"--enable-static",
549549
"--enable-strip",
550550
}
551-
// x264's aarch64 assembly uses GNU assembler macros (const, endconst, T())
552-
// that aren't compatible with LLVM's integrated assembler on macOS
553-
if os == "darwin" && runtime.GOARCH == "arm64" {
554-
args = append(args, "--disable-asm")
555-
}
556-
return args
557551
},
558552
PostExtract: func(srcPath string) error {
559-
// x264 needs to find nasm explicitly on x86/x86_64
560-
// ARM architectures use the C compiler as assembler instead
561-
if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" {
553+
// x264 needs explicit assembler configuration per architecture
554+
switch runtime.GOARCH {
555+
case "amd64", "386":
556+
// x86/x86_64 uses nasm for assembly
562557
os.Setenv("AS", "nasm")
558+
case "arm64":
559+
// aarch64 .S files contain macros (T(), const, endconst) that require
560+
// C preprocessor expansion before assembly. Using clang as AS ensures
561+
// the preprocessor runs, unlike bare 'as' which skips preprocessing.
562+
os.Setenv("AS", "clang")
563563
}
564564
return nil
565565
},

0 commit comments

Comments
 (0)