December 21, 2023

On Sunday, 17 December 2023 at 12:08:40 UTC, Johan wrote:

>

On Wednesday, 13 December 2023 at 18:32:50 UTC, Renato wrote:

>

On Wednesday, 4 October 2023 at 11:01:08 UTC, Johan wrote:

>

On Tuesday, 3 October 2023 at 23:55:05 UTC, confuzzled wrote:

>

Any known workaround for this most recent issue on macOS Sonoma? The file I'm compiling contains a blank main() without any imports but this error shows up on everything I've attempted to compile since upgrading to Sonoma.

(dmd-2.105.2) confuzzled@test ~ % dmd add
ld: multiple errors: symbol count from symbol table and dynamic symbol table differ in '/Users/confuzzled/add.o' in '/Users/confuzzled/add.o'; address=0x0 points to section(2) with no content in '/Users/confuzzled/dlang/dmd-2.105.2/osx/lib/libphobos2.a3177'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1

Try passing -ld_classic to the linker. (dmd -L-ld_classic)

https://github.com/ldc-developers/ldc/issues/4501#issuecomment-1738295459

-Johan

Thanks, it worked for me as well on MacOS Sonoma! The issue you've linked has been resolved now. I am completely new to D, so if I may ask, how often do they release? The fix was merged 2 weeks ago, should we expect a release within a few weeks or it's not released that often?

Release will not be in next weeks, first DMD 2.106.1 should be released, then probably a few weeks later LDC 1.36 will be released.

-Johan

This problem is really serious, I think you should consider a release sooner.

I am trying to get started with dub but this issue keeps popping up.

All I did was this:

dub init myproject
dub add silly
dub build

silly is a nicer test runner, which is exactly what I wanted... but the build fails with linker issues:

▶ dub build
dub build
    Starting Performing "debug" build using /Library/D/dmd/bin/dmd for x86_64.
    Building pledged ~master: building configuration [application]
     Linking pledged
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 0x1000741C9 ('anon' + 457 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x1000741E6 ('anon' + 486 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x1000742C9 ('anon' + 713 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x100074311 ('anon' + 785 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x100074367 ('anon' + 871 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x1000743A2 ('anon' + 930 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x1000743BE ('anon' + 958 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: warning: pointer not aligned at address 0x1000743FA ('anon' + 1018 from /Users/renato/.dub/cache/pledged/~master/build/application-debug-lpSnJT5zFAFHM32hZ8QYUw/pledged.o)
ld: unaligned pointer(s) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
Error /Library/D/dmd/bin/dmd failed with exit code 1.

Unless silly is completely broken, it seems like this is a linker issue again.

December 21, 2023

On Thursday, 21 December 2023 at 18:06:51 UTC, Renato wrote:

>

Unless silly is completely broken, it seems like this is a linker issue again.

Hello, why not use ldc instead of dmd for macOS?

sudo ln -f -s /path/to/ldc/compiler/bin/ldc2 /usr/local/bin/ldc2
sudo ln -f -s /path/to/ldc/compiler/bin/dub /usr/local/bin/dub

You will get multiple targets (dub -a arm64-apple-macos and -a x86_64)

December 21, 2023

On Thursday, 21 December 2023 at 19:29:31 UTC, Guillaume Piolat wrote:

>

On Thursday, 21 December 2023 at 18:06:51 UTC, Renato wrote:

>

Unless silly is completely broken, it seems like this is a linker issue again.

Hello, why not use ldc instead of dmd for macOS?

sudo ln -f -s /path/to/ldc/compiler/bin/ldc2 /usr/local/bin/ldc2
sudo ln -f -s /path/to/ldc/compiler/bin/dub /usr/local/bin/dub

You will get multiple targets (dub -a arm64-apple-macos and -a x86_64)

LDC is slow and makes huge multi-MB binaries (is that normal?). DMD seemed much better to me.

But at least LDC works :) so will use that for now.

December 21, 2023

On Thursday, 21 December 2023 at 22:19:07 UTC, Renato wrote:

>

LDC is slow and makes huge multi-MB binaries (is that normal?). DMD seemed much better to me.

But at least LDC works :) so will use that for now.

On my setup ldc generates small binaries and dmd generates huge ones. The difference is about dynamically linking Phobos or not. Try ldc with --link-defaultlib-shared

December 21, 2023

On Thursday, 21 December 2023 at 19:29:31 UTC, Guillaume Piolat wrote:

>

On Thursday, 21 December 2023 at 18:06:51 UTC, Renato wrote:

>

Unless silly is completely broken, it seems like this is a linker issue again.

Hello, why not use ldc instead of dmd for macOS?

sudo ln -f -s /path/to/ldc/compiler/bin/ldc2 /usr/local/bin/ldc2
sudo ln -f -s /path/to/ldc/compiler/bin/dub /usr/local/bin/dub

You will get multiple targets (dub -a arm64-apple-macos and -a x86_64)

It still doesn't work when I try to run tests with silly and ldc2, and try to use this configuration (for better error messages):

configuration "unittest" {
  dflags "-checkaction=context"
}

Error:

▶ dub test
             Generating test runner configuration 'pledged-test-unittest' for 'unittest' (library).
    Starting Performing "unittest" build using /Users/renato/dlang/ldc-1.35.0/bin/ldc2 for x86_64.
    Building pledged ~master: building configuration [pledged-test-unittest]
     Linking pledged-test-unittest
Undefined symbols for architecture x86_64:
  "__D4core8internal7dassert__T14_d_assert_failTPkZQuFNaNbNiNfMxAyaMxPkZAya", referenced from:
      __D3std3uni__T8CowArrayTSQwQu8GcPolicyZQz17freeThisReferenceMFNaNbNiNfZv in pledged-test-unittest.o
  "__D4core8internal7dassert__T14_d_assert_failTxkZ__TQxTiZQBcFNaNbNiNfMxAyaMKxkMxiZAya", referenced from:
      __D3std3uni__T9sliceBitsVmi0Vmi8ZQt__T6opCallTwZQkFNaNbNiNfwZk in pledged-test-unittest.o
      __D3std3uni__T9sliceBitsVmi8Vmi21ZQu__T6opCallTwZQkFNaNbNiNfwZk in pledged-test-unittest.o
  "__D4core8internal7dassert__T24miniFormatFakeAttributesTmZQBdFNaNbNiNfMKxmZAya", referenced from:
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTmZQBbFNaNbNiNfMxAyaMKxmMKxmZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTmZQBbFNaNbNiNfMxAyaMKxmMxmZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTmZQBbFNaNbNiNfMxAyaMxmMKxmZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTiZQBbFNaNbNiNfMxAyaMxmMxiZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTiZQBbFNaNbNiNfMxAyaMKxmMxiZAya in pledged-test-unittest.o
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 /Users/renato/dlang/ldc-1.35.0/bin/ldc2 failed with exit code 1.
(ldc-1.35.0)
December 22, 2023

On Thursday, 21 December 2023 at 23:25:55 UTC, Renato wrote:

>

ld: symbol(s) not found for architecture x86_64

Make sure you're using the "osx-universal" package in order to have both arch.
https://github.com/ldc-developers/ldc/releases/tag/v1.35.0

That said, for consumer software it may be a good idea to use eg: LDC 1.28 for x86_64 and LDC 1.35 for arm64 builds. You can stich the binaries together, which will give compatibility with all macOS from 10.12 up to Sonoma (well, if you also: codesign, notarize, make a DMG...).

December 22, 2023

On Friday, 22 December 2023 at 12:49:35 UTC, Guillaume Piolat wrote:

>

On Thursday, 21 December 2023 at 23:25:55 UTC, Renato wrote:

>

ld: symbol(s) not found for architecture x86_64

Make sure you're using the "osx-universal" package in order to have both arch.
https://github.com/ldc-developers/ldc/releases/tag/v1.35.0

That said, for consumer software it may be a good idea to use eg: LDC 1.28 for x86_64 and LDC 1.35 for arm64 builds. You can stich the binaries together, which will give compatibility with all macOS from 10.12 up to Sonoma (well, if you also: codesign, notarize, make a DMG...).

I installed using the script as the downloads page suggests... it installed the correct architecture for me:

▶ curl -fsS https://dlang.org/install.sh | bash -s ldc
Downloading https://dlang.org/d-keyring.gpg
######################################################################## 100.0%
Downloading https://dlang.org/install.sh
######################################################################## 100.0%
The latest version of this script was installed as ~/dlang/install.sh.
It can be used it to install further D compilers.
Run `~/dlang/install.sh --help` for usage information.

Downloading and unpacking https://github.com/ldc-developers/ldc/releases/download/v1.35.0/ldc2-1.35.0-osx-x86_64.tar.xz
######################################################################## 100.0%
Using dub 1.34.0 shipped with ldc-1.35.0

Run `source ~/dlang/ldc-1.35.0/activate` in your shell to use ldc-1.35.0.
This will setup PATH, LIBRARY_PATH, LD_LIBRARY_PATH, DMD, DC, and PS1.
Run `deactivate` later on to restore your environment.

Are you sure this shouldn't have just worked?

I then tried as suggested above to install the universal release:

~/dlang/install.sh install  ldc2-1.35.0-osx-universal
Downloading and unpacking https://github.com/ldc-developers/ldc/releases/download/v1.35.0-osx-universal/ldc2-1.35.0-osx-universal-osx-x86_64.tar.xz
curl: (22) The requested URL returned error: 404

I don't want to just download the binary and unpack it myself because apparently the install script's "activate" command sets up a bunch of environment variables that I will need later.

Can't install.sh install this universal release?

December 22, 2023

On Friday, 22 December 2023 at 12:49:35 UTC, Guillaume Piolat wrote:

>

On Thursday, 21 December 2023 at 23:25:55 UTC, Renato wrote:

>

ld: symbol(s) not found for architecture x86_64

Make sure you're using the "osx-universal" package in order to have both arch.
https://github.com/ldc-developers/ldc/releases/tag/v1.35.0

That said, for consumer software it may be a good idea to use eg: LDC 1.28 for x86_64 and LDC 1.35 for arm64 builds. You can stich the binaries together, which will give compatibility with all macOS from 10.12 up to Sonoma (well, if you also: codesign, notarize, make a DMG...).

I went to the effort of downloading this universal release, manually creating the activate script with the right paths to avoid issues (as the download didn't include one)... and it still fails.

▶ dub test
             Generating test runner configuration 'pledged-test-unittest' for 'unittest' (library).
    Starting Performing "unittest" build using /Users/renato/dlang/ldc2-1.35.0-osx-universal/bin/ldc2 for x86_64.
    Building pledged ~master: building configuration [pledged-test-unittest]
     Linking pledged-test-unittest
Undefined symbols for architecture x86_64:
  "__D4core8internal7dassert__T14_d_assert_failTPkZQuFNaNbNiNfMxAyaMxPkZAya", referenced from:
      __D3std3uni__T8CowArrayTSQwQu8GcPolicyZQz17freeThisReferenceMFNaNbNiNfZv in pledged-test-unittest.o
  "__D4core8internal7dassert__T14_d_assert_failTxkZ__TQxTiZQBcFNaNbNiNfMxAyaMKxkMxiZAya", referenced from:
      __D3std3uni__T9sliceBitsVmi0Vmi8ZQt__T6opCallTwZQkFNaNbNiNfwZk in pledged-test-unittest.o
      __D3std3uni__T9sliceBitsVmi8Vmi21ZQu__T6opCallTwZQkFNaNbNiNfwZk in pledged-test-unittest.o
  "__D4core8internal7dassert__T24miniFormatFakeAttributesTmZQBdFNaNbNiNfMKxmZAya", referenced from:
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTmZQBbFNaNbNiNfMxAyaMKxmMKxmZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTmZQBbFNaNbNiNfMxAyaMKxmMxmZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTmZQBbFNaNbNiNfMxAyaMxmMKxmZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTiZQBbFNaNbNiNfMxAyaMxmMxiZAya in pledged-test-unittest.o
      __D4core8internal7dassert__T14_d_assert_failTmZ__TQwTiZQBbFNaNbNiNfMxAyaMKxmMxiZAya in pledged-test-unittest.o
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 /Users/renato/dlang/ldc2-1.35.0-osx-universal/bin/ldc2 failed with exit code 1.
(ldc-1.35.0)

You can see it was using the universal release.

I even tried setting the LIBRARY_PATH and LD_LIBRARY_PATH to use lib-arm64 and lib-ios-x86_64 besides the obvious lib-x86_64 but nothing worked.

I'm afraid I've lost interest to make it work at this point :(

December 22, 2023

Some general advice:

1 - use dub from LDC's package (this may solve some arm64 vs x86 issues when on Apple Silicon CPU)
2 - when you use a new or different compiler, you have to rebuild all packages. So clear your dub cache.

I think point 2 is causing your issues.

-Johan

December 22, 2023

On Friday, 22 December 2023 at 17:45:27 UTC, Renato wrote:

>

I'm afraid I've lost interest to make it work at this point :(

Did you add "-L-ld_classic"?