FTBFS on MacOS (aarch64)
Testing, HighPublic

Assigned To
None
Authored By
tfry
Mon, Sep 21, 12:25 PM

Description

Trying to build libgcrypt master from source on MacOS (aarch64; M​4 processor) fails with:

Making all in mpi
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -std=gnu23 -DHAVE_CONFIG_H -I. -I../../libgcrypt-202609211218/mpi -I..  -I../src -I../../libgcrypt-202609211218/src    -MT mpih-add1-asm.lo -MD -MP -MF .deps/mpih-add1-asm.Tpo -c -o mpih-add1-asm.lo mpih-add1-asm.S
libtool: compile:  gcc -std=gnu23 -DHAVE_CONFIG_H -I. -I../../libgcrypt-202609211218/mpi -I.. -I../src -I../../libgcrypt-202609211218/src -MT mpih-add1-asm.lo -MD -MP -MF .deps/mpih-add1-asm.Tpo -c mpih-add1-asm.S  -fno-common -DPIC -o .libs/mpih-add1-asm.o
[TMPDIR]/mpih-add1-asm-9d6625.s:62:1: error: Unfinished frame!

Increasing the number of parallel jobs shows four more similar errors in the mpi source folder:

[TMPDIR]/mpih-mul2-asm-d2b41c.s:99:1: error: Unfinished frame!
[TMPDIR]/mpih-mul1-asm-850234.s:87:1: error: Unfinished frame!
[TMPDIR]/mpih-sub1-asm-f39320.s:62:1: error: Unfinished frame!
[TMPDIR]/mpih-add1-asm-b910b6.s:62:1: error: Unfinished frame!
[TMPDIR]/mpih-mul3-asm-426568.s:112:1: error: Unfinished frame!
git bisect points to commit 9b684f4a448e8948b4c1fd1316320fa97fd8109a (libgcrypt-1.12.2 is the latest release I can build, successfully).

Event Timeline

• werner added a subscriber: • werner.

Can you try with ./configure --disable-asm

With ./configure --disable-asm the build succeeeds.

Based on this I discovered that macOS aarch64 assembly uses "%%" as separator instead ";". On macOS ";" is marker for start of comment. This also means that none of the Aarch64 assembly (SHA&AES acceleration, etc) has not been building for macOS aarch64 builds.

If it (clang with the name of gcc) can support other assembler with -no-integrated-as, it's worth a try.

• werner added projects: Bug Report, MacOS.

No, for Apple Silicon, /usr/bin/as is Apple's LLVM assembler. So, -no-integrated-as won't work.

I looked LLVM, and the separator seems hard-coded as (in llvm-project/compiler-rt/lib/builtins/assembly.h):

#if defined(__APPLE__) && defined(__aarch64__)
#define SEPARATOR %%
#else
#define SEPARATOR ;
#endif

So, there seems no way but we need to modify our source code.

Side note:

  • For 32-bit ARM, GNU as has an option --mccs (TI CodeComposer Studio syntax compatibility mode) to allow the comment line with ;,
  • Internally, GNU as has support to change the separator character(s) (possibly at runtime like 32-bit ARM), but it does not support string like %%.

BTW, homebrew uses --disable-asm option of configure.

For ;, here is a possible patch (it doesn't support the case of GNU as on macOS aarch64, though):

There may be other syntax differences (and errors). Please try.

I found that cfarm.net has macOS machine where I can test building. There's few issues to solve:

  1. Global symbols need prefix underscore. Need to handle this for:
    • configure.ac aarch64 asm checks
    • cipher/ aarch64 assembly files
  2. read-only data section, SECTION_RODATA, needs to be defined differently (.section __TEXT,__const)
  3. %% separator instead of ; in assembly files
  4. Local asm labels start with L instead of .L

I'm thinking of using additional preprocessor script to handle 3. and 4. bulk conversions on darwin-aarch64. So in configure.ac we'd setup CCAS="\$(SHELL) \$(top_srcdir)/build-aux/darwin-aarch64-as.sh $CCAS" if host is aarch64-apple-darwin.

Here's patch (tested with macOS aarch64 machine cfarm104.cfarm.net):

• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Sep 28, 2:25 AM

Since my apple-silicon.diff doesn't work with GNU Toolchain, I think that the approach is not better.

@jukivili 's patch is better, IIUC, it even works well when a user uses GNU Toolchain, since it won't introduce %% but replacing ';' into newline by the additional script.

• werner changed the task status from Open to Testing.Sat, Oct 3, 1:30 PM