Compiler switch for integer comparison/promotion to catch a simple error

2022-05-28 Thread frame via Digitalmars-d-learn

Is there a compiler switch to catch this kind of error?

```d
ulong v = 1;
writeln(v > -1);
```

IMHO the compiler should bail a warning if it sees a logic 
comparison between signed and unsigned / different integer sizes. 
There is 50% chance that a implicit conversion was not intended.


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

2022-05-28 Thread kdevel via Digitalmars-d-learn

On Friday, 18 March 2022 at 19:42:02 UTC, Anonymouse wrote:

On Thursday, 17 March 2022 at 14:00:45 UTC, kdevel wrote:
If ```import std.regex;``` is commented out or if 
```-checkaction=context``` is removed from the cmd line the 
unittest passes. Can anybody reproduce this?


https://run.dlang.io/is/GYDUBz

File an issue, I'd say. The worst thing that can happen is that 
someone flags it as a duplicate.


Issue 22902 - dmd 2.099 regression: unittest -checkaction=context 
and import std.regex causes link error (edit)

https://issues.dlang.org/show_bug.cgi?id=22902


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn
On Saturday, 28 May 2022 at 15:10:25 UTC, Steven Schveighoffer 
wrote:

[...]
Is this specific to gdc, or does it happen for other compilers 
as well?


The former.


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn

On Saturday, 28 May 2022 at 14:37:07 UTC, kdevel wrote:

dmd:

```
$ dmd -c ppinsta.d
$ dmd -c parser.d
$ dmd -of=ppinsta ppinsta.o parser.o
$ ./ppinsta
[]
```
(checking ldc/ldmd2 later)


```
$ ldc2 -c ppinsta.d && ldc2 -c parser.d && ldc2 -of=ppinsta 
ppinsta.o parser.o && ./ppinsta

[]

$ ldmd2 -c ppinsta.d && ldmd2 -c parser.d && ldmd2 -of=ppinsta 
ppinsta.o parser.o && ./ppinsta

[]
```

Both okay.


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Steven Schveighoffer via Digitalmars-d-learn

On 5/28/22 10:44 AM, Adam D Ruppe wrote:

On Saturday, 28 May 2022 at 14:16:51 UTC, kdevel wrote:

$ gdc -o ppinsta ppinsta.d parser.d


Compiling together is faster anyway this is prolly what you want most 
the time.


But I know what's going on now, it is the template emission thing, the 
compiler thinks, since it is from std, it was already compiled somewhere 
else and skips it but it isn't actually there so the linker errors.


It should only think that if it sees it instantiated.

If it's instatiated in std, it should be included in the built phobos 
library. If it's not instantiated in std, then the compiler should be 
putting it inside the object file.


Is this specific to gdc, or does it happen for other compilers as well?

-Steve


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn

On Saturday, 28 May 2022 at 14:44:56 UTC, Adam D Ruppe wrote:

On Saturday, 28 May 2022 at 14:16:51 UTC, kdevel wrote:

$ gdc -o ppinsta ppinsta.d parser.d


Compiling together is faster anyway this is prolly what you 
want most the time.


But I know what's going on now, it is the template emission 
thing, the compiler thinks, since it is from std, it was 
already compiled somewhere else and skips it but it isn't 
actually there so the linker errors.


Using

gdc -fall-instantiations -c parser.d


   $ gdc -fall-instantiations -c ppinsta.d
   $ gdc -c parser.d
   $ gdc -o ppinsta ppinsta.o parser.o
   $ ./ppinsta
   []

Works. THX!


Re: Why is the compiled file size so huge?

2022-05-28 Thread Steven Schveighoffer via Digitalmars-d-learn

On 5/27/22 9:40 AM, Alexander Zhirov wrote:
I'm trying to compile a file that weighs 3 kilobytes. I'm also linking a 
self-written dynamic library. I don't understand why the resulting 
executable file is so huge? After all, all libraries are present:


```sh
-rwxr-xr-x 1 root root 6.3M May 27 13:39 app
-rw-r--r-- 1 root root 2.9K May 27 12:57 app.d
-rw-r--r-- 1 root root  25K May 27 13:39 app.o
```



I'd say 2.9k of source is enough to produce a large binary. But looking 
at your *object file*, it shouldn't be much bigger than that, especially 
if all libs are dynamic.


Try ldc2 -v and see if there's any clues as to what else it's linking. 
You should be able also to use nm to spit out all the symbols defined in 
the binary, maybe there's some that you wouldn't expect to be there.


-Steve


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Adam D Ruppe via Digitalmars-d-learn

On Saturday, 28 May 2022 at 14:16:51 UTC, kdevel wrote:

$ gdc -o ppinsta ppinsta.d parser.d


Compiling together is faster anyway this is prolly what you want 
most the time.


But I know what's going on now, it is the template emission 
thing, the compiler thinks, since it is from std, it was already 
compiled somewhere else and skips it but it isn't actually there 
so the linker errors.


Using

gdc -fall-instantiations -c parser.d

Might generate it in that parser.o getting it to link. Might need 
to be used in all builds but I *think* just here, hard to say 
without a test.


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn

On Saturday, 28 May 2022 at 13:55:09 UTC, Tejas wrote:

On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
I am trying to build a project with GDC. It successfully 
compiles with dmd and ldmd2. When I use gdc in one go the 
binary is successfully build:


[...]


Is seperate compilation working successfully for dmd and ldc?


dmd:

```
$ dmd -c ppinsta.d
$ dmd -c parser.d
$ dmd -of=ppinsta ppinsta.o parser.o
$ ./ppinsta
[]
```
(checking ldc/ldmd2 later)

The only bug I know of regarding seperate compilation is 
https://issues.dlang.org/show_bug.cgi?id=20641





Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn

On Saturday, 28 May 2022 at 14:03:13 UTC, Adam D Ruppe wrote:

On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
gdc -o ppinsta ppinsta.o esah.o evaluate.o jsr.o jsw.o 
parser.o ptvr.o stack.o testdatagenerator.o


You might need to add -lgphobos or -lgphobos2 or whatever it is 
called too explicitly.


   gdc -v -o ppinsta ppinsta.o parser.o

It says

   
[...]gcc-12.1/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.1.0/collect2 \

   [...]ppinsta.o parser.o -Bstatic -lgphobos [...]
^



Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn

On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:

Any ideas?


ppinsta.d
```
import std.stdio : write, writeln;
import parser; // <- comment this out and gdc links

void main ()
{
   string [string] h;
   writeln (h);
}
```

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

private immutable auto VariableName = regex("^[a-zA-Z]*$");
```

Compile in one go:
```
$ gdc -o ppinsta ppinsta.d parser.d
$ ./ppinsta
[]
```

Compiled separately:
```
$ gdc -c ppinsta.d
$ gdc -c parser.d
$ gdc -o ppinsta ppinsta.o parser.o
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAyaZQoFNaNfQlZl':
ppinsta.d:(.text+0x11ea): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAyaZQoFQhZ9__lambda2Z__TQCpTQBcZQCxMFNaNfQBpZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAaZQnFNaNfQkZl':
ppinsta.d:(.text+0x16ba): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAaZQnFQgZ9__lambda2Z__TQCoTQBbZQCwMFNaNfQBoZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T20formatValueImplUlongTSQCb5array__T8AppenderTAyaZQoTaZQCdFNaNfKQBpmIbMKxSQDzQDy4spec__T10FormatSpecTaZQpZv':
ppinsta.d:(.text+0x21d9): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T20formatValueImplUlongTSQDg5array__T8AppenderTAyaZQoTaZQCdFKQBlmIbMKxSQFaQDu4spec__T10FormatSpecTaZQpZ10__lambda16Z__TQFvTAaZQGcMFNaNfQmZb'
ppinsta.d:(.text+0x2268): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T20formatValueImplUlongTSQDg5array__T8AppenderTAyaZQoTaZQCdFKQBlmIbMKxSQFaQDu4spec__T10FormatSpecTaZQpZ10__lambda17Z__TQFvTAaZQGcMFNaNfQmZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAwZQnFNaNbNiNfQoZl':
ppinsta.d:(.text+0x2996): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAwZQnFQgZ9__lambda2Z__TQCoTQBbZQCwMFNaNbNiNfQBsZb'

collect2: error: ld returned 1 exit status
```




Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Adam D Ruppe via Digitalmars-d-learn

On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
gdc -o ppinsta ppinsta.o esah.o evaluate.o jsr.o jsw.o parser.o 
ptvr.o stack.o testdatagenerator.o


You might need to add -lgphobos or -lgphobos2 or whatever it is 
called too explicitly.


Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Tejas via Digitalmars-d-learn

On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote:
I am trying to build a project with GDC. It successfully 
compiles with dmd and ldmd2. When I use gdc in one go the 
binary is successfully build:


[...]


Is seperate compilation working successfully for dmd and ldc?

The only bug I know of regarding seperate compilation is 
https://issues.dlang.org/show_bug.cgi?id=20641


gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread kdevel via Digitalmars-d-learn
I am trying to build a project with GDC. It successfully compiles 
with dmd and ldmd2. When I use gdc in one go the binary is 
successfully build:


```
$ gdc -o ppinsta esah.d evaluate.d jsr.d jsw.d parser.d ppinsta.d 
ptvr.d stack.d testdatagenerator.d

```

Though after compiling separately the linking fails:

```
$ make -f Makefile.gdc -j3
gdc -o ppinsta.o -c ppinsta.d
gdc -o esah.o -c esah.d
gdc -o evaluate.o -c evaluate.d
gdc -o jsr.o -c jsr.d
gdc -o jsw.o -c jsw.d
gdc -o parser.o -c parser.d
gdc -o ptvr.o -c ptvr.d
gdc -o stack.o -c stack.d
gdc -o testdatagenerator.o -c testdatagenerator.d
gdc -o ppinsta ppinsta.o esah.o evaluate.o jsr.o jsw.o parser.o 
ptvr.o stack.o testdatagenerator.o
ppinsta.o: In function 
`_D3std6format8internal5write__T8getWidthTAyaZQoFNaNfQlZl':
ppinsta.d:(.text+0x1c5a): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T8getWidthTAyaZQoFQhZ9__lambda2Z__TQCpTQBcZQCxMFNaNfQBpZb'
ppinsta.o: In function 
`_D3std6format8internal5write__T20formatValueImplUlongTSQCb5array__T8AppenderTAyaZQoTaZQCdFNaNfKQBpmIbMKxSQDzQDy4spec__T10FormatSpecTaZQpZv':
ppinsta.d:(.text+0x2bcc): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T20formatValueImplUlongTSQDg5array__T8AppenderTAyaZQoTaZQCdFKQBlmIbMKxSQFaQDu4spec__T10FormatSpecTaZQpZ10__lambda16Z__TQFvTAaZQGcMFNaNfQmZb'
ppinsta.d:(.text+0x2c5b): undefined reference to 
`_D3std9algorithm9searching__T3allSQBg6format8internal5write__T20formatValueImplUlongTSQDg5array__T8AppenderTAyaZQoTaZQCdFKQBlmIbMKxSQFaQDu4spec__T10FormatSpecTaZQpZ10__lambda17Z__TQFvTAaZQGcMFNaNfQmZb'

collect2: error: ld returned 1 exit status
make: *** [ppinsta] Error 1
```

Any ideas?


Re: Why is the compiled file size so huge?

2022-05-28 Thread zjh via Digitalmars-d-learn

On Friday, 27 May 2022 at 13:40:25 UTC, Alexander Zhirov wrote:
I'm trying to compile a file that weighs 3 kilobytes. I'm also 
linking a self-written dynamic library. I don't understand why 
the resulting executable file is so huge?



I just switched from `32-bit` to 64 bit, but the '64' bit program 
is too large.

I'm going to continue compiling into 32-bit.



Re: Why is the compiled file size so huge?

2022-05-28 Thread user1234 via Digitalmars-d-learn

On Friday, 27 May 2022 at 13:40:25 UTC, Alexander Zhirov wrote:
I'm trying to compile a file that weighs 3 kilobytes. I'm also 
linking a self-written dynamic library. I don't understand why 
the resulting executable file is so huge? After all, all 
libraries are present:




I'd take a look with IDA or hydra to check the details (maybe 
something is statically linked after all, that should be visible 
by inspecting the names view) but one thing to understand in a 
first time is that


1. even if druntime and phobos are dynamic libraries all the 
template instances are generated in your binary.
2. use of some module has for effect to create huge static 
tables. I think to all the UTF stuff and also std regex.


Re: Why is the compiled file size so huge?

2022-05-28 Thread rempas via Digitalmars-d-learn

On Friday, 27 May 2022 at 13:40:25 UTC, Alexander Zhirov wrote:
I'm trying to compile a file that weighs 3 kilobytes. I'm also 
linking a self-written dynamic library. I don't understand why 
the resulting executable file is so huge? After all, all 
libraries are present:

[...]


I did a similar question in a C forum regarding an huge file 
sizes of GCC compared to manually writing assembly and linking 
(at least for the smallest possible program on Linux) and well... 
You won't get an answer!


Re: UI Library

2022-05-28 Thread Sergey via Digitalmars-d-learn

On Saturday, 28 May 2022 at 02:39:41 UTC, Jack wrote:

On Friday, 20 May 2022 at 12:32:37 UTC, ryuukk_ wrote:
Avoid GTK, it's bloated, GTK4 looks like a toolkit to design 
mobile apps, and you need runtime dependencies on windows


adam's gui library is very nice, 0 dependencies

I personally prefer IMGUI, 0 dependencies, you bring the



could you send me please the link for this lib?

windowing library of your choice, i pick GLFW since it's 
minimal


IMGUI is fully capable, someone made a Spotify client with it!

https://user-images.githubusercontent.com/3907907/81094458-d20d9200-8f03-11ea-81e0-e72c0063b3a7.png


There are several bindings.
https://code.dlang.org/search?q=Imgui