Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldc2 with -g flag fails to link on Apple M1 Pro (aarch64) with unaligned pointer #3864

Closed
schveiguy opened this issue Nov 4, 2021 · 60 comments · Fixed by #3868
Closed

ldc2 with -g flag fails to link on Apple M1 Pro (aarch64) with unaligned pointer #3864

schveiguy opened this issue Nov 4, 2021 · 60 comments · Fixed by #3868

Comments

@schveiguy
Copy link
Contributor

I removed everything I could think of:

% cat testit.d
extern(C) void main() {}
% ldc2 -betterC testit.d
% ./testit              
% ldc2 -betterC -g testit.d
ld: warning: pointer not aligned at address 0x10000402D (anon + 45 from testit.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
@schveiguy schveiguy changed the title ldc2 with -g flag fails to link on Apple M1 Pro arch (aarch64) ldc2 with -g flag fails to link on Apple M1 Pro (aarch64) with unaligned pointer Nov 4, 2021
@thewilsonator
Copy link
Contributor

thewilsonator commented Nov 4, 2021

Some sleuthing reveals that -platform_version macos 12.0.0 12.0 is the argument passed to the linker cause this to fail. On Big Sur (OS version 11) -platform_version macos 11.0.0 12.0 is passed instead.

This latter command works, even with the same object file. The first number of that argument is the min platform version.

@jacob-carlborg
Copy link
Contributor

As a workaround, if I set the MACOSX_DEPLOYMENT_TARGET environment variable to 11 it will link successfully.

@kinke
Copy link
Member

kinke commented Nov 8, 2021

I guess ld64 pedantically checks DWARF alignment specs and complains about an invalid one; I guess alignment of pointer itself vs. pointee alignment or something along these lines.

kinke added a commit to kinke/ldc that referenced this issue Nov 10, 2021
As clang doesn't seem to either. This *might* fix ldc-developers#3864.
kinke added a commit to kinke/ldc that referenced this issue Nov 10, 2021
As clang doesn't seem to either. This *might* fix ldc-developers#3864.
@kinke
Copy link
Member

kinke commented Nov 26, 2021

Thx for testing, Steven. 2nd guess:

// LDC-LLVM >= 6.0.1:
// On Mac, emit __debug_line section in __DWARF segment as regular (non-debug)
// section, like DMD, to enable file/line infos in backtraces. See
// https://github.com/dlang/dmd/commit/2bf7d0db29416eacbb01a91e6502140e354ee0ef.
static llvm::cl::opt<bool, true> preserveDwarfLineSection(
"preserve-dwarf-line-section",
llvm::cl::desc("Mac: preserve DWARF line section during linking for "
"file/line infos in backtraces. Defaults to true."),
llvm::cl::Hidden, llvm::cl::ZeroOrMore,
llvm::cl::location(ldc::emitMachODwarfLineAsRegularSection),
llvm::cl::init(true));

(testable via -preserve-dwarf-line-section=false)

@schveiguy
Copy link
Contributor Author

2nd guess

That seems to have worked. However, I now do not have file/line numbers as I did when targeting MacOS 11.

steves@MacBook-Pro objdraw % export MACOSX_DEPLOYMENT_TARGET=11                                                                      
steves@MacBook-Pro objdraw % cat testthrow.d                   
void foo()
{
    throw new Exception("hi");
}

void main()
{
    foo();
}
steves@MacBook-Pro objdraw % ldc2 -g testthrow.d 
steves@MacBook-Pro objdraw % ./testthrow 
object.Exception@testthrow.d(3): hi
----------------
testthrow.d:3 void testthrow.foo() [0x1021d422b]
testthrow.d:8 _Dmain [0x1021d4237]
steves@MacBook-Pro objdraw % ldc2 -g -preserve-dwarf-line-section=false testthrow.d
steves@MacBook-Pro objdraw % ./testthrow                                           
object.Exception@testthrow.d(3): hi
----------------
??:? void testthrow.foo() [0x10062022b]
??:? _Dmain [0x100620237]
steves@MacBook-Pro objdraw % unset MACOSX_DEPLOYMENT_TARGET
steves@MacBook-Pro objdraw % ldc2 -g testthrow.d                                   
ld: warning: pointer not aligned at address 0x100294081 (anon + 129 from testthrow.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
steves@MacBook-Pro objdraw % ldc2 -g -preserve-dwarf-line-section=false testthrow.d
steves@MacBook-Pro objdraw % ./testthrow
object.Exception@testthrow.d(3): hi
----------------
??:? void testthrow.foo() [0x104820c5b]
??:? _Dmain [0x104820c67]

@kinke
Copy link
Member

kinke commented Nov 26, 2021

Thx for testing again - great, so that's it. Apple might have changed the linker scripts in more recent SDKs then. Note that this is a LLVM-hack on our side, as workaround for a druntime limitation (cannot use default .dSYM files) tracked in https://issues.dlang.org/show_bug.cgi?id=20510.

@schveiguy
Copy link
Contributor Author

OK. For now, I guess I will stick with my original workaround, since i get line/file data out of it.

@schveiguy
Copy link
Contributor Author

A question about the "LLVM hack". Is that with the switch or default behavior? Because I would think it's good for the default ldc2 to actually link on MacOS Monterey.

@kinke
Copy link
Member

kinke commented Nov 26, 2021

The hack is enabled by default - as it wasn't known to cause trouble and provides the expected file/line infos. Changing that logic depending on target macOS version probably requires specifying a versioned macOS triple via -mtriple and/or ugly env var/host detection logic. Do these apparently fatal linker warnings happen for x64 too, or is that ARM64 only? What about the other Darwin variants? Etc.

@schveiguy
Copy link
Contributor Author

schveiguy commented Nov 26, 2021

When I get around to updating my old mac to Monterey, I can test there.

Scratch that, my old macbook pro is too old to receive the update. Someone else would have to test x64

@kinke
Copy link
Member

kinke commented Nov 26, 2021

That said, @Geod24 seems to have started a .dSYM implementation, so it might make more sense to push that rather than wasting time on hack applicability detection here.

@jacob-carlborg
Copy link
Contributor

Do these apparently fatal linker warnings happen for x64 too

It works fine on x86-64.

@jacob-carlborg
Copy link
Contributor

That said, Geod24 seems to have started a .dSYM implementation, so it might make more sense to push that rather than wasting time on hack applicability detection here.

LDC will then need to start producing .dSYM files.

@kinke
Copy link
Member

kinke commented Nov 26, 2021

LDC will then need to start producing .dSYM files.

I thought that's what ld64 does by default (at least with -preserve-dwarf-line-section=false). Anyway, PRs from Apple users are always welcome. :) Speaking of which, I could use some help in #3871 too - LDC cannot be linked due to missing libm, libz, libxml2… I'm wondering whether that has to do with

MACOSX_DEPLOYMENT_TARGET: 10.9
(as the official LDC Mac x64 build has been compatible with 10.9+ for a while and that ideally wouldn't have to change)

@jacob-carlborg
Copy link
Contributor

Speaking of which, I could use some help in #3871 too

I answered in the PR.

@p0nce
Copy link
Contributor

p0nce commented Dec 18, 2021

@Geod24 Possible to sponsor https://issues.dlang.org/show_bug.cgi?id=20510 in order to have #3864 fixed?
Definately would be interested in keeping Mac compat.

Contact me for testing x86_64 or arm64 binaries, macOS Monterey (arm64/Rosetta) and 10.14 (x86_64) installed here.

@dnadlinger
Copy link
Member

I sadly don't have too much time for LDC development these days, but feel free to ping me if you need any testing as well – just got a M1 Max/Monterey box.

@JohanEngelen
Copy link
Member

I sadly don't have too much time for LDC development these days, but feel free to ping me if you need any testing as well – just got a M1 Max/Monterey box.

I now too have an M1 Macbook Air, so can test too.

Off topic: Already ran into troubles of course :). For now, I managed to build LDC (arm64 binary) by setting MACOSX_DEPLOYMENT_TARGET=11 and using the LDC 1.27.0 arm64 released binary as bootstrapping compiler. Running cmake the first time, it errors with

CMake Error at cmake/Modules/ExtractDMDSystemLinker.cmake:42 (message):
  Failed to link empty D program using
  '/Users/johan/dcompilers/ldc-1.27.1/bin/ldmd2 -wi -link-debuglib':

  ld: library not found for -lpthread

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  Error: /Library/Developer/CommandLineTools/usr/bin/cc failed with status: 1
Call Stack (most recent call first):
  CMakeLists.txt:670 (include)

simply rerunning cmake "fixes" it, and happily finishes.

@JohanEngelen
Copy link
Member

JohanEngelen commented Dec 28, 2021

I cannot reproduce this on M1 Macbook Air with LDC master 6542126.

My local LDC is built by setting MACOSX_DEPLOYMENT_TARGET=11 (only when running cmake, not when executing the tests below, as you can see from the first line) and using the LDC 1.27.1 arm64 released binary as bootstrapping compiler.

❯ echo $MACOSX_DEPLOYMENT_TARGET

❯ file bin/ldc2
bin/ldc2: Mach-O 64-bit executable arm64
❯ bin/ldc2 --version
LDC - the LLVM D compiler (1.28.1-git-6542126):
  based on DMD v2.098.1 and LLVM 12.0.1
  built with LDC - the LLVM D compiler (1.27.1)
  Default target: arm64-apple-darwin21.1.0
  ...
❯ cat testbadlink.d
import core.stdc.stdio;
extern(C) void main() {
	printf("Hello!");
}
❯ bin/ldc2 -betterC -g -run testbadlink.d
Hello!
❯ bin/ldc2 -betterC -run testbadlink.d
Hello!

No errors.

The released LDC 1.27.1 arm64 binaries do indeed not work:

❯ ~/dcompilers/ldc-1.27.1/bin/ldc2 --version
LDC - the LLVM D compiler (1.27.1):
  based on DMD v2.097.2 and LLVM 12.0.1
  built with LDC - the LLVM D compiler (1.27.1)
  Default target: arm64-apple-darwin21.1.0
 ...
❯ ~/dcompilers/ldc-1.27.1/bin/ldc2 -betterC -run testbadlink.d
Hello!
❯ ~/dcompilers/ldc-1.27.1/bin/ldc2 -betterC -g -run testbadlink.d
ld: warning: pointer not aligned at address 0x100008032 (anon + 50 from /var/folders/gm/9sswz8kd70n8tsdbct_fb0vh0000gp/T/objtmp-ldc-029e51/testbadlink.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

Building LDC 1.27.1 locally:

❯ bin/ldc2 --version
LDC - the LLVM D compiler (1.27.1):
  based on DMD v2.097.2 and LLVM 12.0.1
  built with LDC - the LLVM D compiler (1.27.1)
  Default target: arm64-apple-darwin21.1.0
  ...
❯ bin/ldc2 -betterC -run testbadlink.d
Hello!
❯ bin/ldc2 -betterC -g -run testbadlink.d
Hello!

So perhaps something wrong in the way the LDC 1.27.1 release package is made?

@jacob-carlborg
Copy link
Contributor

So perhaps something wrong in the way the LDC 1.27.1 release package is made?

Hmm, I guessing MACOSX_DEPLOYMENT_TARGET could cause this, when 1.27.1 release package is built.

@JohanEngelen
Copy link
Member

Extra info: if I use my self-built ldc-1.27.1 to again build ldc-1.27.1, I no longer need MACOSX_DEPLOYMENT_TARGET=11 to build ldc.

@jacob-carlborg
Copy link
Contributor

@JohanEngelen what's the deployment target of that binary? If you run otool -l <binary> and look for the LC_BUILD_VERSION load command, then look at the minos field.

@JohanEngelen
Copy link
Member

@JohanEngelen what's the deployment target of that binary? If you run otool -l <binary> and look for the LC_BUILD_VERSION load command, then look at the minos field.

On the binaries produced by the new LDC (that does not have the -g problem discussed here):

      cmd LC_BUILD_VERSION
  cmdsize 32
 platform 1
    minos 12.0
      sdk 12.1
   ntools 1
     tool 3
  version 710.1

@jacob-carlborg
Copy link
Contributor

The prebuilt LDC 1.27.0 has minos set to 11.0. I'm wondering if that's what's causing the issue. But the deployment target should be determined at runtime (of the compiler). The deployment target of the compiler shouldn't matter, as long as it's possible to run the binary.

@JohanEngelen
Copy link
Member

Does minos = 12.0 really mean that the binary cannot be run on <12 macOS?

@schveiguy
Copy link
Contributor Author

1.30.0 does not work with the MACOSX_DEPLOYMENT_TARGET=11 variable set.

release build does work, even without that set.

Using -preserve-dwarf-line-section=false as recommended in the release also doesn't work.

@jblachly
Copy link

Naive question: why does the front end matter? That is, I assume other LLVM based compilers (Rust and Clang etc.) don't have this problem, and yet I thought it was the backend that ultimately produced the object code that is apparently offensive to the linker.

@schveiguy
Copy link
Contributor Author

I think LDC uses a modified backend, see notes above.

@kinke
Copy link
Member

kinke commented Aug 28, 2022

Using -preserve-dwarf-line-section=false as recommended in the release also doesn't work.

Did you use that for compilation as stated there, or just for linking? It needs to be disabled when compiling to disable the only relevant LDC-specific LLVM mod here.

@schveiguy
Copy link
Contributor Author

hm... I didn't know it would be a linker flag. I used it in compilation.

@schveiguy
Copy link
Contributor Author

So when you say "it needs to be disabled", do you mean the flag shouldn't be used during compilation, or that it is used during compilation to disable the mod?

@kinke
Copy link
Member

kinke commented Aug 28, 2022

It only affects compilation, so you need to use/disable it when compiling all stuff linked to the final executable. If you do that, you should get vanilla LLVM codegen, where I definitely don't expect the alignment linker errors. Are you still testing the dummy executable from the original post, without any (non-C) deps linked at all? (The error would still be expected when linking with -link-defaultlib-debug for example - as it's been precompiled with (implicit) -preserve-dwarf-line-section.)

@schveiguy
Copy link
Contributor Author

schveiguy commented Aug 28, 2022

I added the flag in to the dflags part of dub, but maybe it wasn't put into the dependency builds? Is there a config file for ldc like dmd.conf? EDIT: found it in etc. Going to try that.

@kinke
Copy link
Member

kinke commented Aug 28, 2022

Aha, so a dub build. I recommend using the DFLAGS env variable to enforce a flag for all compilations of a dub build, incl. rebuilding dependencies. (It might not affect the dub linker cmdlines though, but that doesn't matter here).

And yes, there's etc/ldc2.conf, mentioned in the bundled readme files.

@schveiguy
Copy link
Contributor Author

Success! What can I expect not to work correctly with that flag enabled?

@kinke
Copy link
Member

kinke commented Aug 28, 2022

You don't get file/line infos in druntime exception backtraces, because druntime requires that DWARF data in the binary itself, while IIRC LLVM or ld64 moved to NOT preserving it for the linked executable. (To be loaded from the original object files / static lib archives directly via .dSYM indirection or so as far as I gathered - but I don't know anything about Apple's ecosystem.)

@jacob-carlborg
Copy link
Contributor

jacob-carlborg commented Aug 29, 2022

I added the flag in to the dflags part of dub, but maybe it wasn't put into the dependency builds?

@schveiguy IIRC there was a feature added recently to Dub which allows you to pass flags down to dependencies.

@jacob-carlborg
Copy link
Contributor

because druntime requires that DWARF data in the binary itself, while IIRC LLVM or ld64 moved to NOT preserving it for the linked executable. (To be loaded from the original object files / static lib archives directly via .dSYM indirection or so as far as I gathered - but I don't know anything about Apple's ecosystem.)

Here's the full description for those that are interested:

The linker on macOS will remove any debug info, i.e. every section with the S_ATTR_DEBUG flag, this includes everything in the __DWARF section. By using the S_REGULAR flag the linker will not remove this section. This allows to get the filenames and line numbers for backtraces from the executable.

Normally the linker removes all the debug info but adds a reference to the object files. The debugger can then read the object files to get filename and line number information. It's also possible to use an additional tool that generates a separate .dSYM file. This file can then later be deployed with the application if debug info is needed when the application is deployed.

@zoujiaqing
Copy link

I should have also said was that setting it to 12 explicitly does not work! That was the puzzling part to me.

Setting MACOSX_DEPLOYMENT_TARGET to 12 is the same as not setting MACOSX_DEPLOYMENT_TARGET at all on a system that runs macOS 12. By default the compiler and linker target the host system. Obviously there's something wrong when targeting macOS 12, regardless if it's by setting MACOSX_DEPLOYMENT_TARGET or not setting it at all.

Has anyone tried the macOS 13 beta?

@zoujiaqing
Copy link

Has anyone tried the macOS 13 beta?

macOS 13 released.

@p0nce
Copy link
Contributor

p0nce commented Oct 25, 2022

I'm trying LDC 1.28 + macOS 13.0 Ventura + -g + Xcode 14.0.1 and so far the error is completely unchanged.
Perhaps there is more detail about unaligned pointers.

guill@Mac-mini-de-Guillaume qoix % dub -a arm64-apple-macos -f
Performing "debug" build using /Users/guill/Desktop/compilers/ldc2-1.28.0-osx-x86_64/bin/ldc2 for aarch64, arm_hardfloat.
intel-intrinsics 1.10.8: building configuration "library"...
gamut 0.0.7+commit.58.g20e6491: building configuration "boost+mit"...
qoix ~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: 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 0x10031117F ('anon' + 4479 from .dub/build/application-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-D46690DE96F4C33034DE2FEECA70F166/qoix.o)
ld: warning: pointer not aligned at address 0x1003268F2 ('anon' + 241 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.jpegload.o))
ld: warning: pointer not aligned at address 0x1003330D7 ('anon' + 251 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.pngload.o))
ld: warning: pointer not aligned at address 0x100335111 ('anon' + 68 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.qoi.o))
ld: warning: pointer not aligned at address 0x10033566B ('anon' + 84 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.qoi10b.o))
ld: warning: pointer not aligned at address 0x100335EC1 ('anon' + 72 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.qoi2avg.o))
ld: warning: pointer not aligned at address 0x100336609 ('anon' + 86 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.qoiplane.o))
ld: warning: pointer not aligned at address 0x100336B66 ('anon' + 80 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.codecs.stb_image_write.o))
ld: warning: pointer not aligned at address 0x100337B27 ('anon' + 228 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.image.o))
ld: warning: pointer not aligned at address 0x100338B9A ('anon' + 73 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.internals.binop.o))
ld: warning: pointer not aligned at address 0x100338DB9 ('anon' + 75 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.internals.cstring.o))
ld: warning: pointer not aligned at address 0x1003392EF ('anon' + 869 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.internals.mutex.o))
ld: warning: pointer not aligned at address 0x10033951A ('anon' + 105 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.internals.types.o))
ld: warning: pointer not aligned at address 0x100339F93 ('anon' + 60 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.io.o))
ld: warning: pointer not aligned at address 0x10033A455 ('anon' + 75 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.plugin.o))
ld: warning: pointer not aligned at address 0x10033A5C7 ('anon' + 170 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.plugins.dds.o))
ld: warning: pointer not aligned at address 0x10033A90E ('anon' + 131 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.plugins.jpeg.o))
ld: warning: pointer not aligned at address 0x10033B29F ('anon' + 170 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.plugins.qoix.o))
ld: warning: pointer not aligned at address 0x10033B7BA ('anon' + 63 from ../../.dub/build/boost+mit-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-EA29A1AD9CFA5506CEA0451F45EF838F/libgamut.a(gamut.types.o))
ld: warning: pointer not aligned at address 0x10033B8B3 ('anon' + 213 from ../../../../.dub/packages/intel-intrinsics-1.10.8/intel-intrinsics/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-53EBED0E482E2CC07DF0CBFE7BCC4F70/libintel-intrinsics.a(inteli.emmintrin.o))
ld: warning: pointer not aligned at address 0x10033C872 ('anon' + 129 from ../../../../.dub/packages/intel-intrinsics-1.10.8/intel-intrinsics/.dub/build/library-debug-posix.osx.darwin-aarch64.arm_hardfloat-ldc_v1.28.0-53EBED0E482E2CC07DF0CBFE7BCC4F70/libintel-intrinsics.a(inteli.internals.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
/Users/guill/Desktop/compilers/ldc2-1.28.0-osx-x86_64/bin/ldc2 failed with exit code 1.

I admit I have not fully followed and don't know if there is a workaround.

@zoujiaqing
Copy link

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.

@JohanEngelen
Copy link
Member

dub build --compiler=ldc2 --arch=arm64-apple-macos

...

this is completely unrelated.

@zoujiaqing
Copy link

dub build --compiler=ldc2 --arch=arm64-apple-macos

...

this is completely unrelated.

How to build it?

@kinke
Copy link
Member

kinke commented Dec 5, 2022

How to build it?

You got a reply on the forum: https://forum.dlang.org/post/tmgbro$1b3u$1@digitalmars.com. If in doubt, use an official LDC release from GitHub; no idea about the homebrew stuff.

@JohanEngelen
Copy link
Member

I'm working on this, got something implemented that uses atos, needs polishing but should be good.

@zoujiaqing
Copy link

How to build it?

You got a reply on the forum: https://forum.dlang.org/post/tmgbro$1b3u$1@digitalmars.com. If in doubt, use an official LDC release from GitHub; no idea about the homebrew stuff.

zoujiaqing@mac server % which dub
/Users/zoujiaqing/Programs/ldc/bin/dub
zoujiaqing@mac server % dub --version
DUB version 1.29.0, built on Jul 20 2022
zoujiaqing@mac server % ldc2 --version
LDC - the LLVM D compiler (1.30.0):
  based on DMD v2.100.1 and LLVM 14.0.3
  built with LDC - the LLVM D compiler (1.30.0)
  Default target: arm64-apple-darwin22.1.0
  Host CPU: cyclone
  http://dlang.org - http://wiki.dlang.org/LDC

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    amdgcn     - AMD GCN GPUs
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    avr        - Atmel AVR Microcontroller
    bpf        - BPF (host endian)
    bpfeb      - BPF (big endian)
    bpfel      - BPF (little endian)
    hexagon    - Hexagon
    lanai      - Lanai
    mips       - MIPS (32-bit big endian)
    mips64     - MIPS (64-bit big endian)
    mips64el   - MIPS (64-bit little endian)
    mipsel     - MIPS (32-bit little endian)
    msp430     - MSP430 [experimental]
    nvptx      - NVIDIA PTX 32-bit
    nvptx64    - NVIDIA PTX 64-bit
    ppc32      - PowerPC 32
    ppc32le    - PowerPC 32 LE
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    r600       - AMD GPUs HD2XXX-HD6XXX
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    sparc      - Sparc
    sparcel    - Sparc LE
    sparcv9    - Sparc V9
    systemz    - SystemZ
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    ve         - VE
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
    xcore      - XCore
zoujiaqing@mac server % ~/Programs/ldc/bin/dub run
Performing "debug" build using /Users/zoujiaqing/Programs/ldc/bin/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-A117F359EB78BC810BDE4A43C61EA410/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-3845054F4A360DA6EC39A6439A220013/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-642115DE0E516005CED050361BF5F15F/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
/Users/zoujiaqing/Programs/ldc/bin/ldc2 failed with exit code 1.

I used it, but couldn't build it.

Add -b plain resolved ;)

zoujiaqing@mac server % dub run --build=plain 
Performing "plain" build using /Users/zoujiaqing/Programs/ldc/bin/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: target for configuration "application" is up to date.
To force a rebuild of up-to-date targets, run again with --force.
Running server 
Edit source/app.d to start your project.

Thanks @schveiguy @kinke and every one!

JohanEngelen added a commit that referenced this issue Dec 28, 2022
…n backtraces. (#4291)

* macOS debuginfo: add support for using `atos` to get file:line info in backtraces.
Resolves issue #3864

* Return to LLVM default of emitting __debug_line section in __DWARF segment as a debug section (not regular)

* Re-enable test now that issue #3280 is fixed.

* Allow full path names in exception file:line debug output.

* Allow full path names in exception file:line debug output.

* Add changelog entry
@kinke
Copy link
Member

kinke commented Feb 24, 2023

Fixed by PR linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants