December 22, 2023

On Friday, 22 December 2023 at 17:50:47 UTC, Johan wrote:

>

Some general advice:

1 - use dub from LDC's package (this may solve some arm64 vs x86 issues when on Apple Silicon CPU)

▶ which dub
/Users/renato/dlang/ldc-1.35.0/bin/dub
(ldc-1.35.0)
>

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

No, I removed ~/.dub/cache and nothing changes.

Unfortunately, nothing makes this work:

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

If I remove this things work, but then assertion error messages suck.

>

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"?

That's the first thing I did... without that, LDC still compiles , but logs a huge amount of things like this (it keeps going for a few hundred of these):

ld: warning: no platform load command found in '/Users/renato/.dub/cache/pledged/~master/build/pledged-test-unittest-unittest-n8f2nulDuB1X-8Gdil7wKw/pledged-test-unittest.o', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[2](curl.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[8](zlib.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[9](comparison.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[11](iteration.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[12](mutation.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[14](searching.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[16](sorting.o)', assuming: macOS
ld: warning: no platform load command found in '/Users/renato/dlang/ldc-1.35.0/lib/libphobos2-ldc.a[17](array.o)', assuming: macOS
January 06, 2024
> >

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"?

That's the first thing I did... without that, LDC still compiles , but logs a huge amount of things like this (it keeps going for a few hundred of these):

I decided to continue with my struggles after all :).

I found out now that this flag is only required on my Mac x86 (Macbook Air with Intel processor), but not on my Mac M1 (ARM), even though I am on the exact same MacOS version in both machines.

So I had to do this on my dub file:

lflags "-ld_classic" platform="osx-x86_64"

That works fine locally.

But unfortunately, this is causing my build on GitHub Actions to fail on macos-latest (the flag is not recognized: ld: library not found for -ld_classic).

https://github.com/renatoathaydes/dzipper/actions/runs/7433575723/job/20226754138

I just had a quick look and GH Actions seems to be using MacOS 12.

My laptops are using MacOS Sonoma (14.1.1).

Does dub allow specifying not just the OS and architecture, but the OS version?? Probably not , right? This linker issue is such a messy problem to have.

January 20

On Friday, 22 December 2023 at 17:50:47 UTC, Johan wrote:

>

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

Hi again, I hate to repeat myself, but the linker issues on MacOS keep happening, even after using this in the dub recipe:

lflags "-ld_classic"

Even though this helps, every now and then I am faced with a horrible error like this (happened on multiple projects):

ld: warning: pointer not aligned at address 0x10017FA3A ('anon' + 115 from ../../../.dub/cache/prettyprint/1.0.9/build/library-unittest-zRys5rzGP6krRGvFrhQ1nw/libprettyprint.a(primitives_64_42b.o))
ld: warning: pointer not aligned at address 0x10017FACD ('anon' + 115 from ../../../.dub/cache/prettyprint/1.0.9/build/library-unittest-zRys5rzGP6krRGvFrhQ1nw/libprettyprint.a(primitives_65_55a.o))

.... hundreds of lines just like this


ld: warning: pointer not aligned at address 0x100199171 ('anon' + 117 from ../../../.dub/cache/tested/0.9.5/build/library-unittest-GNkuLeNnFlMZmRhvBdmNgA/libtested.a(lifetime_2ae_75b.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 /Users/renato/dlang/dmd-2.106.1/osx/bin/dmd failed with exit code 1.

It doesn't matter if I use LDC or DMD. Both cause the same error.

I've tried cleaning the DUB cache like this:

rm -rf ~/.dub/cache

But it doesn't help.

It's very frustrating because I'm close to finishing my project, but this kind of random error really delays me... it seems that as I keep changing code, the linker eventually starts working again! I must be hitting some "bad path" in the compiler.

So, if anyone who understands about linking on MacOS could have a look, here's a commit on the project I'm currently working on which shows this problem:

https://github.com/renatoathaydes/dzipper/commit/54d1f90f18a17d87d71195df68d02089ca4cf27c

If you checkout this commit, just run dub test and you should see the problem on MacOS Sonoma.

Notice that the current state of my code is "in progress" so some stuff may not even be working properly yet, the tests may not even be passing, that's fine (if I only I could run the tests)... but as the error is on the linker, I believe it's compiling properly and there should never be any linker errors like this.

January 20

On Saturday, 20 January 2024 at 20:35:16 UTC, Renato wrote:

>

On Friday, 22 December 2023 at 17:50:47 UTC, Johan wrote:

>

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

Hi again, I hate to repeat myself, but the linker issues on MacOS keep happening, even after using this in the dub recipe:

lflags "-ld_classic"

Even though this helps, every now and then I am faced with a horrible error like this (happened on multiple projects):

ld: warning: pointer not aligned at address 0x10017FA3A ('anon' + 115 from ../../../.dub/cache/prettyprint/1.0.9/build/library-unittest-zRys5rzGP6krRGvFrhQ1nw/libprettyprint.a(primitives_64_42b.o))
ld: warning: pointer not aligned at address 0x10017FACD ('anon' + 115 from ../../../.dub/cache/prettyprint/1.0.9/build/library-unittest-zRys5rzGP6krRGvFrhQ1nw/libprettyprint.a(primitives_65_55a.o))

.... hundreds of lines just like this


ld: warning: pointer not aligned at address 0x100199171 ('anon' + 117 from ../../../.dub/cache/tested/0.9.5/build/library-unittest-GNkuLeNnFlMZmRhvBdmNgA/libtested.a(lifetime_2ae_75b.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 /Users/renato/dlang/dmd-2.106.1/osx/bin/dmd failed with exit code 1.

It doesn't matter if I use LDC or DMD. Both cause the same error.

I've tried cleaning the DUB cache like this:

rm -rf ~/.dub/cache

But it doesn't help.

It's very frustrating because I'm close to finishing my project, but this kind of random error really delays me... it seems that as I keep changing code, the linker eventually starts working again! I must be hitting some "bad path" in the compiler.

So, if anyone who understands about linking on MacOS could have a look, here's a commit on the project I'm currently working on which shows this problem:

https://github.com/renatoathaydes/dzipper/commit/54d1f90f18a17d87d71195df68d02089ca4cf27c

If you checkout this commit, just run dub test and you should see the problem on MacOS Sonoma.

Notice that the current state of my code is "in progress" so some stuff may not even be working properly yet, the tests may not even be passing, that's fine (if I only I could run the tests)... but as the error is on the linker, I believe it's compiling properly and there should never be any linker errors like this.

dub might not be passing this flag down to dependencies..

Try this env variable:

LDFLAGS="$LDFLAGS -Wl,-ld_classic" dub build

If that doesn't work, try this one:

MACOSX_DEPLOYMENT_TARGET=11 dub build

January 21

On Saturday, 20 January 2024 at 21:12:12 UTC, ryuukk_ wrote:

>

dub might not be passing this flag down to dependencies..

Try this env variable:

LDFLAGS="$LDFLAGS -Wl,-ld_classic" dub build

That didn't help.

>

If that doesn't work, try this one:

MACOSX_DEPLOYMENT_TARGET=11 dub build

This did work! Thanks.

Any update on fixing the linker issues so that such workarounds won't be needed?

1 2 3
Next ›   Last »