Re: macOS Sonoma Linker Issue

2023-12-21 Thread Renato via Digitalmars-d-learn
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)
```


Re: macOS Sonoma Linker Issue

2023-12-21 Thread Julian Fondren via Digitalmars-d-learn

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


Re: macOS Sonoma Linker Issue

2023-12-21 Thread Renato via Digitalmars-d-learn
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.


Re: macOS Sonoma Linker Issue

2023-12-21 Thread Guillaume Piolat via Digitalmars-d-learn

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)


Re: macOS Sonoma Linker Issue

2023-12-21 Thread Renato via Digitalmars-d-learn

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.a[3177](config_a68_4c3.o)'
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.


Re: Change to unittest?

2023-12-21 Thread DLearner via Digitalmars-d-learn

On Thursday, 21 December 2023 at 10:38:16 UTC, DLearner wrote:
[...]
And now, returning to the problem after several hours Christmas 
shopping, everything seems to work perfectly!




Re: D programming language overview video on Youtube

2023-12-21 Thread aberba via Digitalmars-d-learn

On Sunday, 17 December 2023 at 22:39:56 UTC, Witold Baryluk wrote:
I made a bit random video on D lang for noobs, and people who 
might be interested.


If you program more than one hour in D, do not watch it, but if 
you just found about D, feel free to check it out.


It is not too short, and unscripted, but should give general 
feel of D, its power, major features (with some live coding, 
and exploration of various aspects in real world, including 
debugging), maybe for people who just want to see what it is 
about. And high level overview of the project and features.


https://www.youtube.com/watch?v=_7Xg-E0NoNU


While I am not great at making videos, I think it is good to 
promote D any way possible, as it can compete in many places, 
like Python, Julia, Zig, but people rarely hear about D lang 
these days.


👍


Behaves different on my osx and linux machines

2023-12-21 Thread Christian Köstlin via Digitalmars-d-learn
I have this somehow reduced program that behaves differently on osx and 
linux.



```d
void stdioMain()
{
import std.stdio : readln, writeln;
import std.concurrency : spawnLinked, receive, receiveTimeout, 
LinkTerminated;

import std.variant : Variant;
import std.string : strip;
import std.process : execute;
import core.time : dur;
auto input = spawnLinked(() {
string getInput() {
writeln("Please enter something:");
return readln().strip();
}
string line = getInput();
while (line != "quit")
{
writeln("You entered ", line);
line = getInput();
}
});

bool done = false;
while (!done) {
auto result = ["echo", "Hello World"].execute;
if (result.status != 0)
{
throw new Exception("echo failed");
}
writeln(result.output);
receiveTimeout(dur!"msecs"(-1),
  (LinkTerminated t) {
  writeln("Done");
  done = true;
  },
);
}
writeln("ByeBye");
}

void main(string[] args)
{
stdioMain();
}
`

It should just read from stdin in one separate thread and on the main 
thread it just executes one `echo` after the other (and tries to find 
out, if the other thread finished).


In linux this behaves as expected, meaning it prints a lot of hello worlds.

In osx on the other hand it prints 'please enter something', waits for 
my input, prints it, and outputs one hello world.


What did I do wrong?

Kind regards,
Christian

p.s.: i am using ldc-1.35.0 osx version is 13.6.


Change to unittest?

2023-12-21 Thread DLearner via Digitalmars-d-learn

This applies to dmd version v2.106.0-dirty under Windows.
Module containing several functions with unittests, no 'main' 
function.
Was testing ok some time ago, producing '1/1 modules PASSED 
unittests' message.


Today,
```
 dmd -main -unittest -run 
```
produced nothing, just a return to the command prompt.
(FWIW no corresponding .obj or .exe files in directory)

So, reversed one of the unittests to produce failure, and 
repeated.

Same result. (Suggesting unittests not being run).

Then reset unittest, and ran without the -run.
Saw .obj and .exe files.
Ran .exe: no messages.

Then (maybe this sheds some light) changed the test to produce 
failure, ran without -run, then ran resulting .exe

And got
```
1/1 modules FAILED unittests
```

Has there been some sort of change to the -unittest function?