Thread overview
How to compiler dlang code on Apple M1?
Dec 03, 2022
zoujiaqing
Dec 13, 2022
zoujiaqing
Dec 13, 2022
rikki cattermole
Dec 14, 2022
Sergey
December 03, 2022
dub build --compiler=ldc2 --arch=arm64-apple-macos
    Starting Performing "debug" build using ldc2 for aarch64, arm_hardfloat.
    Building taggedalgebraic 0.11.22: building configuration [library]
    Building eventcore 0.9.20+commit.4.g6744ae7: building configuration [cfrunloop]
    Building server ~master: building configuration [application]
     Linking server
ld: warning: ignoring file ../../../.dub/packages/taggedalgebraic-0.11.22/taggedalgebraic/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-60F6D8BEA34F8F5E792A98EA27B02D2235262A4E0795062F91FA90871411535D/libtaggedalgebraic.a, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/ldc/1.30.0_1/lib/libdruntime-ldc.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file .dub/build/application-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-7AC1A4B8AFD7D9F59DB01E667A3DCF19DD437F41E741F5937BDCF58FAE6AA922/server.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-ED6AFABD5E24BB6BCED6FD74F2DE88CF39B648360CE187983206459095D4677D/libeventcore.a, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/ldc/1.30.0_1/lib/libphobos2-ldc.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found 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
Error ldc2 failed with exit code 1.
December 03, 2022

On 12/3/22 1:59 PM, zoujiaqing wrote:

>
dub build --compiler=ldc2 --arch=arm64-apple-macos
     Starting Performing "debug" build using ldc2 for aarch64, arm_hardfloat.
     Building taggedalgebraic 0.11.22: building configuration [library]
     Building eventcore 0.9.20+commit.4.g6744ae7: building configuration [cfrunloop]
     Building server ~master: building configuration [application]
      Linking server
ld: warning: ignoring file ../../../.dub/packages/taggedalgebraic-0.11.22/taggedalgebraic/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-60F6D8BEA34F8F5E792A98EA27B02D2235262A4E0795062F91FA90871411535D/libtaggedalgebraic.a, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/ldc/1.30.0_1/lib/libdruntime-ldc.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file .dub/build/application-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-7AC1A4B8AFD7D9F59DB01E667A3DCF19DD437F41E741F5937BDCF58FAE6AA922/server.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-ED6AFABD5E24BB6BCED6FD74F2DE88CF39B648360CE187983206459095D4677D/libeventcore.a, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/ldc/1.30.0_1/lib/libphobos2-ldc.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
   "_main", referenced from:
      implicit entry/start for main executable
ld: symbol(s) not found 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
Error ldc2 failed with exit code 1.

The issue is dub. Make sure you are using the dub built for ARM.

What Apple does is if any program in the same process group is x86 specific, then all the executed programs that are universal (including the linker) will switch to that mode.

The linker thinks you are building on x86, even though the compiler is doing ARM64. I ran into this early on too. Switching to the dub that ships with ldc built for ARM solved it!

-Steve

December 13, 2022

On Saturday, 3 December 2022 at 20:33:59 UTC, Steven Schveighoffer wrote:

>

The issue is dub. Make sure you are using the dub built for ARM.

What Apple does is if any program in the same process group is x86 specific, then all the executed programs that are universal (including the linker) will switch to that mode.

The linker thinks you are building on x86, even though the compiler is doing ARM64. I ran into this early on too. Switching to the dub that ships with ldc built for ARM solved it!

-Steve

Performing "debug" build using ldc2 for aarch64, arm_hardfloat.
taggedalgebraic 0.11.22: target for configuration "library" is up to date.
eventcore 0.9.20+commit.4.g6744ae7: target for configuration "cfrunloop" is up to date.
server ~master: building configuration "application"...
Linking...
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: pointer not aligned at address 0x100334231 ('anon' + 561 from .dub/build/application-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-FA51B7352B8B88D87B3B8911362A8A52/server.o)
ld: warning: pointer not aligned at address 0x1003350DB ('anon' + 2025 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.driver.o))
ld: warning: pointer not aligned at address 0x1003398EB ('anon' + 1759 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.driver.o))
ld: warning: pointer not aligned at address 0x10033B426 ('anon' + 696 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.events.o))
ld: warning: pointer not aligned at address 0x10033C2A1 ('anon' + 618 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.kqueue.o))
ld: warning: pointer not aligned at address 0x10033C942 ('anon' + 1186 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.pipes.o))
ld: warning: pointer not aligned at address 0x10033EE5E ('anon' + 1258 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.processes.o))
ld: warning: pointer not aligned at address 0x100342E2A ('anon' + 872 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.sockets.o))
ld: warning: pointer not aligned at address 0x1003479E2 ('anon' + 630 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.watchers.o))
ld: warning: pointer not aligned at address 0x100349562 ('anon' + 1437 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.threadedfile.o))
ld: warning: pointer not aligned at address 0x10034B9F2 ('anon' + 1597 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.timer.o))
ld: warning: pointer not aligned at address 0x10034D833 ('anon' + 372 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.consumablequeue.o))
ld: warning: pointer not aligned at address 0x10034E57E ('anon' + 244 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.dlist.o))
ld: warning: pointer not aligned at address 0x10034EC95 ('anon' + 1228 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.ioworker.o))
ld: warning: pointer not aligned at address 0x100351681 ('anon' + 4868 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.utils.o))
ld: warning: pointer not aligned at address 0x10036F251 ('anon' + 270 from ../../../.dub/packages/taggedalgebraic-0.11.22/taggedalgebraic/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-2F44BAD74994DE04344CC9119014729D/libtaggedalgebraic.a(taggedalgebraic.o))
ld: unaligned pointer(s) for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: /usr/bin/cc failed with status: 1
ldc2 failed with exit code 1.

So hard ..

December 14, 2022
Which ldc did you install?

Was it: ldc2-1.30.0-osx-arm64.tar.xz
December 13, 2022

On 12/13/22 9:35 AM, zoujiaqing wrote:

>

On Saturday, 3 December 2022 at 20:33:59 UTC, Steven Schveighoffer wrote:

>

The issue is dub. Make sure you are using the dub built for ARM.

What Apple does is if any program in the same process group is x86 specific, then all the executed programs that are universal (including the linker) will switch to that mode.

The linker thinks you are building on x86, even though the compiler is doing ARM64. I ran into this early on too. Switching to the dub that ships with ldc built for ARM solved it!

-Steve

Performing "debug" build using ldc2 for aarch64, arm_hardfloat.
taggedalgebraic 0.11.22: target for configuration "library" is up to date.
eventcore 0.9.20+commit.4.g6744ae7: target for configuration "cfrunloop" is up to date.
server ~master: building configuration "application"...
Linking...
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: alignment (1) of atom 'anon' is too small and may result in unaligned pointers
ld: warning: pointer not aligned at address 0x100334231 ('anon' + 561 from .dub/build/application-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-FA51B7352B8B88D87B3B8911362A8A52/server.o)
ld: warning: pointer not aligned at address 0x1003350DB ('anon' + 2025 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.driver.o))
ld: warning: pointer not aligned at address 0x1003398EB ('anon' + 1759 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.driver.o))
ld: warning: pointer not aligned at address 0x10033B426 ('anon' + 696 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.events.o))
ld: warning: pointer not aligned at address 0x10033C2A1 ('anon' + 618 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.kqueue.o))
ld: warning: pointer not aligned at address 0x10033C942 ('anon' + 1186 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.pipes.o))
ld: warning: pointer not aligned at address 0x10033EE5E ('anon' + 1258 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.processes.o))
ld: warning: pointer not aligned at address 0x100342E2A ('anon' + 872 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.sockets.o))
ld: warning: pointer not aligned at address 0x1003479E2 ('anon' + 630 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.posix.watchers.o))
ld: warning: pointer not aligned at address 0x100349562 ('anon' + 1437 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.threadedfile.o))
ld: warning: pointer not aligned at address 0x10034B9F2 ('anon' + 1597 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.drivers.timer.o))
ld: warning: pointer not aligned at address 0x10034D833 ('anon' + 372 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.consumablequeue.o))
ld: warning: pointer not aligned at address 0x10034E57E ('anon' + 244 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.dlist.o))
ld: warning: pointer not aligned at address 0x10034EC95 ('anon' + 1228 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.ioworker.o))
ld: warning: pointer not aligned at address 0x100351681 ('anon' + 4868 from ../../eventcore/.dub/build/cfrunloop-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-18F6DB0DFA53563841F49715E25DF4FC/libeventcore.a(eventcore.internal.utils.o))
ld: warning: pointer not aligned at address 0x10036F251 ('anon' + 270 from ../../../.dub/packages/taggedalgebraic-0.11.22/taggedalgebraic/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.30.0-2F44BAD74994DE04344CC9119014729D/libtaggedalgebraic.a(taggedalgebraic.o))
ld: unaligned pointer(s) for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: /usr/bin/cc failed with status: 1
ldc2 failed with exit code 1.

So hard ..

Yeah, that's a known issue: https://github.com/ldc-developers/ldc/issues/3864

Try building with -b plain to avoid the debug build

-Steve

December 13, 2022

On 12/13/22 10:20 AM, Steven Schveighoffer wrote:

>

Yeah, that's a known issue: https://github.com/ldc-developers/ldc/issues/3864

Try building with -b plain to avoid the debug build

Oh, also, I have MACOSX_DEPLOYMENT_TARGET=11 in my environment, that helps to avoid it as well.

-Steve

December 14, 2022

On Tuesday, 13 December 2022 at 15:21:41 UTC, Steven Schveighoffer wrote:

>

On 12/13/22 10:20 AM, Steven Schveighoffer wrote:

>

Yeah, that's a known issue: https://github.com/ldc-developers/ldc/issues/3864

Try building with -b plain to avoid the debug build

Oh, also, I have MACOSX_DEPLOYMENT_TARGET=11 in my environment, that helps to avoid it as well.

-Steve

This export solves the issue (at least for me). Thanks Steven!