#166·blink

link failure: `pointer not aligned at _kWhence+0x4` (macOS 14.4)

Author: quantimnotCreated Mar 7, 2024Updated Sep 11, 2024

Error

ld: building fixups: pointer not aligned at _kWhence+0x4 from o//blink/blink.a[124](strace.o)

Failing Build Command

bash
./configure && gmake -j

Relevant Source

c
#ifndef thatispacked
#define thatispacked __attribute__((__packed__))
#endif
struct thatispacked MagicNumber {
  int x;
  const char *s;
};
const struct MagicNumber kWhence[] = {
    {SEEK_SET_LINUX, "SEEK_SET"},  //
    {SEEK_CUR_LINUX, "SEEK_CUR"},  //
    {SEEK_END_LINUX, "SEEK_END"},  //
};

Resolution

Disable packing: CPPFLAGS="-Dthatispacked="

bash
{ ./configure CPPFLAGS="-Dthatispacked=" && gmake -j; } >o/build.stdout 2>o/build.stderr && gmake -j check >o/check.stdout 2>o/check.stderr

PASSED (323 / 323 tests (1 skipped))

Versions

bash
uname -v

Darwin Kernel Version 23.4.0: Wed Feb 21 21:51:37 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T8112

bash
pkgutil --pkg-info com.apple.pkg.CLTools_Executables

package-id: com.apple.pkg.CLTools_Executables version: 15.3.0.0.1.1708646388 volume: / location: / install-time: 1709746099

bash
"$(xcode-select -p)/usr/bin/cc" -v

Apple clang version 15.0.0 (clang-1500.3.9.4) Target: arm64-apple-darwin23.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

bash
"$(xcode-select -p)/usr/bin/ld" -v

@(#)PROGRAM:ld PROJECT:ld-1053.12 BUILD 19:09:13 Feb 1 2024 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k armv7m armv7em LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29) TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)

bash
"$(xcode-select -p)/usr/bin/ld-classic" -v

@(#)PROGRAM:ld-classic PROJECT:ld64-951.9 BUILD 20:36:32 Jan 26 2024 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em LTO support using: LLVM version 15.0.0 (static support for 29, runtime is 29) TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)

References