Re: freebsd dub linker error

2022-03-17 Thread rikki cattermole via Digitalmars-d-learn



On 18/03/2022 5:56 PM, rikki cattermole wrote:

Are you trying to build dub on Android?

Android support for ldc is currently broken to due to removal of a 
linker that is currently required for TLS support.


https://github.com/ldc-developers/ldc/issues/3918


My bad I didn't see FreeBSD.

Similar issue, quite possibly related given the old version 2.069.0 
being referenced.


https://github.com/ldc-developers/ldc/pull/3106


Re: freebsd dub linker error

2022-03-17 Thread rikki cattermole via Digitalmars-d-learn

Are you trying to build dub on Android?

Android support for ldc is currently broken to due to removal of a 
linker that is currently required for TLS support.


https://github.com/ldc-developers/ldc/issues/3918


I like dlang but i don't like dub

2022-03-17 Thread Alain De Vos via Digitalmars-d-learn

Dlang includes some good ideas.
But dub pulls in so much stuff. Too much for me.
I like things which are clean,lean,little,small.
But when i use dub it links with so many libraries.
Are they really needed ?
And how do you compare to pythons pip.
Feel free to elaborate.



Re: How to exclude function from being imported in D language?

2022-03-17 Thread Era Scarecrow via Digitalmars-d-learn

On Tuesday, 8 March 2022 at 22:28:27 UTC, bauss wrote:
What D just needs is a way to specify the entry point, in which 
it just defaults to the first main function found, but could be 
any function given.


 Which is similar to what Java does.

 When i was first learning Java in a company i would make main() 
and have it run all the unittests of that particular module, then 
have a different file that actually combined all the tools 
together to run the program. Though when making the jar I'd 
specify which one actually was needed. But this was... 10 years 
ago.







freebsd dub linker error

2022-03-17 Thread Alain De Vos via Digitalmars-d-learn
I disabled 32bit code maybe this created the following error 
while building dub :


[00:02:18] 
===
[00:02:18] ===>

[00:02:18] ===>  Configuring for dub-1.14.0
[00:02:23] 
===
[00:02:23] ===>

[00:02:23] ===>  Building for dub-1.14.0
[00:02:41] build.sh: cannot open 2.069.0: No such file or 
directory

[00:02:41] Using existing version file.
[00:02:41] Running ldmd2...
[00:02:58] Serializing composite type BuildRequirements which has 
no serializable fields
[00:02:58] Serializing composite type BuildOptions which has no 
serializable fields
[00:02:59] source/dub/dub.d(1602): Deprecation: function 
`std.typecons.Nullable!(PackageRecipe).Nullable.get_` is 
deprecated - Implicit conversion with `alias Nullable.get this` 
will be removed after 2.096. Please use `.get` explicitly.
[00:02:59] source/dub/packagesuppliers/maven.d(81): Deprecation: 
module `std.xml` is deprecated - Will be removed from Phobos in 
2.101.0. If you still need it, go to 
https://github.com/DigitalMars/undeaD
[00:02:59] source/dub/project.d(288): Deprecation: variable `c` 
is shadowing variable `dub.project.Project.validate.c`. Rename 
the `foreach` variable.
[00:03:00] source/dub/generators/build.d(338): Deprecation: 
module `std.digest.digest` is deprecated - import std.digest 
instead of std.digest.digest. std.digest.digest will be removed 
in 2.101

[00:04:19] ld: error: undefined hidden symbol: __start___minfo
[00:04:19] >>> referenced by sdl.d
[00:04:19] >>>   bin/dub.o:(ldc.register_dso)
[00:04:19]
[00:04:19] ld: error: undefined hidden symbol: __stop___minfo
[00:04:19] >>> referenced by sdl.d
[00:04:19] >>>   bin/dub.o:(ldc.register_dso)
[00:04:19] cc: error: linker command failed with exit code 1 (use 
-v to see invocation)

[00:04:19] Error: /usr/bin/cc failed with status: 1
[00:04:19] *** Error code 1
[00:04:19]
[00:04:19] Stop.
[00:04:19] make: stopped in /usr/ports/devel/dub
[00:04:20] =>> Cleaning up wrkdir
[00:04:20] ===>  Cleaning for dub-1.14.0
[00:04:23] build of devel/dub | dub-1.14.0 ended at Fri Mar 18 
03:59:34 CET 2022

[00:04:23] build time: 00:04:23
[00:04:23] !!! build failure encountered !!!



dmd 2.099 regression: unittest -checkaction=context and import std.regex cause lots of undefined references

2022-03-17 Thread kdevel via Digitalmars-d-learn

zstack.d:
```
module zstack;
import std.stdio: writeln;

void bar (int [] i)
{
   writeln ("i: ", i);
}

unittest {
   int [] arr;
   bar (arr);
}
```

zrepo.d:
```
module parser;
import std.regex;
import zstack;
```

```
   $ dmd -g -i -unittest -checkaction=context -main -run zrepro 
2>&1 | ddemangle

```

gives

```
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert._d_assert_fail!(int)._d_assert_fail(scope 
const(immutable(char)[]), const(int))':

[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:41: 
undefined reference to `pure nothrow @nogc @safe bool 
core.internal.dassert.inFinalizer!().inFinalizer()'
zrepro.o: In function `pure nothrow @nogc @safe uint 
std.uni.sliceBits!(0uL, 
8uL).sliceBits.opCall!(dchar).opCall(dchar)':
[...]/dmd2/linux/bin64/../../src/phobos/std/uni/package.d:5593: 
undefined reference to `pure nothrow @nogc @safe 
immutable(char)[] 
core.internal.dassert._d_assert_fail!(const(uint))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(uint), const(int))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert._d_assert_fail!(bool)._d_assert_fail(scope 
const(immutable(char)[]), ref const(bool))':

[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:41: 
undefined reference to `pure nothrow @nogc @safe bool 
core.internal.dassert.inFinalizer!().inFinalizer()'
zrepro.o: In function `pure nothrow @nogc @safe uint 
std.uni.sliceBits!(13uL, 
21uL).sliceBits.opCall!(dchar).opCall(dchar)':
[...]/dmd2/linux/bin64/../../src/phobos/std/uni/package.d:5593: 
undefined reference to `pure nothrow @nogc @safe 
immutable(char)[] 
core.internal.dassert._d_assert_fail!(const(uint))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(uint), const(int))'
zrepro.o: In function `pure nothrow @nogc @safe uint 
std.uni.sliceBits!(8uL, 
13uL).sliceBits.opCall!(dchar).opCall(dchar)':
[...]/dmd2/linux/bin64/../../src/phobos/std/uni/package.d:5593: 
undefined reference to `pure nothrow @nogc @safe 
immutable(char)[] 
core.internal.dassert._d_assert_fail!(const(uint))._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(uint), const(int))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert._d_assert_fail!(ulong)._d_assert_fail!(ulong)._d_assert_fail(scope const(immutable(char)[]), ref const(ulong), const(ulong))':

[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:70: 
undefined reference to `pure nothrow @nogc @safe bool 
core.internal.dassert.inFinalizer!().inFinalizer()'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:75: 
undefined reference to `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref
 const(ulong))'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:77: 
undefined reference to `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref
 const(ulong))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert._d_assert_fail!(ulong)._d_assert_fail!(int)._d_assert_fail(scope const(immutable(char)[]), ref const(ulong), const(int))':

[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:70: 
undefined reference to `pure nothrow @nogc @safe bool 
core.internal.dassert.inFinalizer!().inFinalizer()'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:75: 
undefined reference to `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref
 const(ulong))'
zrepro.o: In function `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert._d_assert_fail!(ulong)._d_assert_fail!(ulong)._d_assert_fail(scope const(immutable(char)[]), ref const(ulong), ref const(ulong))':

[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:70: 
undefined reference to `pure nothrow @nogc @safe bool 
core.internal.dassert.inFinalizer!().inFinalizer()'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:75: 
undefined reference to `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref
 const(ulong))'
[...]/dmd2/linux/bin64/../../src/druntime/import/core/internal/dassert.d:77: 
undefined reference to `pure nothrow @nogc @safe immutable(char)[] 
core.internal.dassert.miniFormatFakeAttributes!(ulong).miniFormatFakeAttributes(ref
 const(ulong))'
collect2: ld returned 1 exit status
Error: linker exited with status 1
```

If ```import std.regex;``` is commented out or if 
```-checkaction=context``` is removed from the cmd line the 
unittest passes. Can anybody reproduce this?


Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 12:19:36 UTC, Patrick Schluter 
wrote:
On Thursday, 17 March 2022 at 12:11:19 UTC, Patrick Schluter 
wrote:
On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter 
wrote:



[...]

Something akin to
```d
auto lookup(ushort key)
{
  return cp949[key-0x8141];
}

[...]


Takes 165 ms to compile with dmd 2.094.2 -O on [godbolt] with 
the whole table generated from the Unicode link.


[godbolt]: https://godbolt.org/z/hEzP7rKnn]


Upps, remove the ] at the end of the link to [godbolt]

[godbolt]: https://godbolt.org/z/hEzP7rKnn


Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 12:11:19 UTC, Patrick Schluter 
wrote:
On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter 
wrote:



[...]

Something akin to
```d
auto lookup(ushort key)
{
  return cp949[key-0x8141];
}

[...]


Takes 165 ms to compile with dmd 2.094.2 -O on [godbolt] with the 
whole table generated from the Unicode link.


[godbolt]: https://godbolt.org/z/hEzP7rKnn]


Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter 
wrote:

On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote:
Hey everyone, I am in need of some help. I have written this 
Windows CP949 encoding table 
https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16.


After some research about how to initialize immutable 
associative arrays people suggested using `shared static 
this()`. So far this worked for me, but I recently discovered 
that DMD cannot compile this in release mode with 
optimizations.


`dub build --build=release`  or `dmd` with `-release -O` fails:

```
code  windows949
function  
zencoding.windows949.fromWindows949!(immutable(ubyte)[]).fromWindows949

code  table
function  zencoding.windows949.table._sharedStaticCtor_L29_C1
dmd failed with exit code -11.
```

I usually compile my projects using LDC where this works fine, 
but I don't want to force others to use LDC because of this 
one problem.


Hence I'd like to ask on how to change the code so that it 
compiles on DMD in release mode (with optimizations). I 
thought about having a computational algorithm instead of an 
encoding table but sadly I could not find any references in 
that regard. Apparently encoding tables seem to be the 
standard.


Why not use a simple static array (not an associative array). 
Where the values are indexed on `key - min(keys)`. Even with 
the holes in the keys (i.e. keys that do not have corresponding 
values) it will be smaller that the constructed associative 
array? The lookup is also faster.

Something akin to
```d
auto lookup(ushort key)
{
  return cp949[key-0x8141];
}

immutable ushort[0xFDFE-0x8141+1] cp949 = [
0x8141-0x8141: 0xAC02,
0x8142-0x8141: 0xAC03,
0x8143-0x8141: 0xAC05,
0x8144-0x8141: 0xAC06,
0x8145-0x8141: 0xAC0B,
0x8146-0x8141: 0xAC0C,
0x8147-0x8141: 0xAC0D,
0x8148-0x8141: 0xAC0E,
0x8149-0x8141: 0xAC0F,
0x814A-0x8141: 0xAC18,
0x814B-0x8141: 0xAC1E,
0x814C-0x8141: 0xAC1F,
0x814D-0x8141: 0xAC21,
0x814E-0x8141: 0xAC22,
0x814F-0x8141: 0xAC23,
0x8150-0x8141: 0xAC25,
0x8151-0x8141: 0xAC26,
0x8152-0x8141: 0xAC27,
0x8153-0x8141: 0xAC28,
0x8154-0x8141: 0xAC29,
0x8155-0x8141: 0xAC2A,
0x8156-0x8141: 0xAC2B,
0x8157-0x8141: 0xAC2E,
0x8158-0x8141: 0xAC32,
0x8159-0x8141: 0xAC33,
0x815A-0x8141: 0xAC34,
0x8161-0x8141: 0xAC35,
0x8162-0x8141: 0xAC36,
0x8163-0x8141: 0xAC37,
...
0xFDFA-0x8141: 0x72A7,
0xFDFB-0x8141: 0x79A7,
0xFDFC-0x8141: 0x7A00,
0xFDFD-0x8141: 0x7FB2,
0xFDFE-0x8141: 0x8A70,
];
```


Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn

On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote:
Hey everyone, I am in need of some help. I have written this 
Windows CP949 encoding table 
https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16.


After some research about how to initialize immutable 
associative arrays people suggested using `shared static 
this()`. So far this worked for me, but I recently discovered 
that DMD cannot compile this in release mode with optimizations.


`dub build --build=release`  or `dmd` with `-release -O` fails:

```
code  windows949
function  
zencoding.windows949.fromWindows949!(immutable(ubyte)[]).fromWindows949

code  table
function  zencoding.windows949.table._sharedStaticCtor_L29_C1
dmd failed with exit code -11.
```

I usually compile my projects using LDC where this works fine, 
but I don't want to force others to use LDC because of this one 
problem.


Hence I'd like to ask on how to change the code so that it 
compiles on DMD in release mode (with optimizations). I thought 
about having a computational algorithm instead of an encoding 
table but sadly I could not find any references in that regard. 
Apparently encoding tables seem to be the standard.


Why not use a simple static array (not an associative array). 
Where the values are indexed on `key - min(keys)`. Even with the 
holes in the keys (i.e. keys that do not have corresponding 
values) it will be smaller that the constructed associative 
array? The lookup is also faster.