jart / jart/blink

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

Open
#166 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
7.6k
Forks
278
PR merge metrics
No merged PRs in 30d

Description

## Error

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

## Failing Build Command

```sh
./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="```

```sh
{ ./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

```sh
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

```sh
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

```sh
"$(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

```sh
"$(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)

```sh
"$(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

- https://developer.apple.com/documentation/xcode/configuring-your-project-to-use-mergeable-libraries

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the reported ./configure && gmake -j failure on macOS 14.4 and inspect the packed MagicNumber definition involving kWhence in strace.o. Compare the default build with CPPFLAGS="-Dthatispacked=" and run gmake -j check; done means establishing a durable build fix while preserving the reported passing test result.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, macos
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.