January 17, 2023

I just fixed a bug in my personal D hobby project. After pushing everything to github, I noticed that it fails to link with the latest LDC on MacOS. The error I'm getting is thus:

ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: pointer not aligned at address 0x3D2C9 ('anon' + 4809 from .dub/build/shared-debug-posix.osx.darwin-x86_64-ldc_v1.30.0-8F420C7727F3804A85668CA76BD80D4C//obj/libdutils.o)
ld: unaligned pointer(s) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: /usr/bin/cc failed with status: 1
FAIL .dub/build/shared-debug-posix.osx.darwin-x86_64-ldc_v1.30.0-8F420C7727F3804A85668CA76BD80D4C/ dutils dynamicLibrary
/Users/runner/hostedtoolcache/dc/ldc2-1.30.0/x64/ldc2-1.30.0-osx-universal/bin/ldc2 failed with exit code 1.

This only happens when building the project as a shared library. It builds perfectly fine as a static library. Any solutions? Thanks in advance.

January 17, 2023

On Tuesday, 17 January 2023 at 03:48:03 UTC, Ruby The Roobster wrote:

>

I just fixed a bug in my personal D hobby project. After pushing everything to github, I noticed that it fails to link with the latest LDC on MacOS. The error I'm getting is thus:

ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: pointer not aligned at address 0x3D2C9 ('anon' + 4809 from .dub/build/shared-debug-posix.osx.darwin-x86_64-ldc_v1.30.0-8F420C7727F3804A85668CA76BD80D4C//obj/libdutils.o)
ld: unaligned pointer(s) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: /usr/bin/cc failed with status: 1
FAIL .dub/build/shared-debug-posix.osx.darwin-x86_64-ldc_v1.30.0-8F420C7727F3804A85668CA76BD80D4C/ dutils dynamicLibrary
/Users/runner/hostedtoolcache/dc/ldc2-1.30.0/x64/ldc2-1.30.0-osx-universal/bin/ldc2 failed with exit code 1.

This only happens when building the project as a shared library. It builds perfectly fine as a static library. Any solutions? Thanks in advance.

This is a known issue: https://github.com/ldc-developers/ldc/issues/3864

Will be fixed in LDC 1.31. https://github.com/ldc-developers/ldc/pull/4291

-Johan