digitalmars.D - 32-bit DMD compiled programs prints "segmentation fault"
- Gilmar =?UTF-8?B?SsO6bmlvcg==?= (6/6) Nov 01 2019 Hello, D programs compiled with 32-bit DMD are not working. I
- Seb (8/14) Nov 01 2019 This unfortunately is a well-known issue:
- Walter Bright (3/20) Nov 01 2019 Why does the PIE code gen work fine on Linux but not Debian?
- Suleyman (4/6) Nov 02 2019 GCC 6 enabled PIE by default, you have to disable it manually
- Walter Bright (3/10) Nov 02 2019 Yes, but I'd like to know exactly what code sequence generated by dmd is...
- Suleyman (18/30) Nov 03 2019 There is nothing wrong with DMD, the problem is in the
- Exil (2/3) Nov 02 2019 How many people are maintaining LDC in comparison to DMD?
- Suleyman (4/7) Nov 02 2019 That wouldn't be a fair question because frontend development is
- Exil (4/12) Nov 03 2019 Those kinds of decisions are in part what affect the
- Suleyman (10/14) Nov 03 2019 Let's just say it's a lot less than LLVM maintainers. Usually the
- Exil (11/26) Nov 04 2019 It doesn't for me, I come across quite a few bugs due to the
- H. S. Teoh (21/36) Nov 04 2019 For the past several releases now, LDC has been closely tracking the
- Adam D. Ruppe (7/12) Nov 05 2019 That's not quite true. They share about 98% of the code, but that
- kinke (12/18) Nov 05 2019 Depends on what you are working on. If it's just the frontend,
- kinke (2/3) Nov 05 2019 Sorry, should have been `-O -inline`.
- kinke (8/12) Nov 05 2019 To roughly quantize that (I got interested myself), counting
- Exil (3/7) Nov 05 2019 If that's truly important it can be done with LLVM. Jai uses LLVM
- Jonathan Marler (3/12) Nov 05 2019 How do you know how fast Jai compiles? I thought it hadn't been
- Ethan (7/10) Nov 06 2019 When I spoke to Jonathan Blow in person about Jai a couple of
- Jonathan Marler (2/12) Nov 06 2019 He said it compiles significantly faster than D?
Hello, D programs compiled with 32-bit DMD are not working. I compiled with dmd and also tested rdmd using version 2.086.0-0 for both 32-bit and the 64-bit with -m32 directive, and it didn't work. I also tested the nightly version I downloaded today and the execution continues to print "segmentation fault (core dumped)". The same error does NOT occur when using LDC.
Nov 01 2019
On Friday, 1 November 2019 at 21:16:23 UTC, Gilmar Júnior wrote:Hello, D programs compiled with 32-bit DMD are not working. I compiled with dmd and also tested rdmd using version 2.086.0-0 for both 32-bit and the 64-bit with -m32 directive, and it didn't work. I also tested the nightly version I downloaded today and the execution continues to print "segmentation fault (core dumped)". The same error does NOT occur when using LDC.This unfortunately is a well-known issue: https://issues.dlang.org/show_bug.cgi?id=19116 tl;dr: use LDC. It's better maintained, faster, has support for tons of architectures etc. Alternatively, you could also switch to ld.gold which you probably want to do anyhow if you can (faster link times!) or x86_64.
Nov 01 2019
On 11/1/2019 4:03 PM, Seb wrote:On Friday, 1 November 2019 at 21:16:23 UTC, Gilmar Júnior wrote:Why does the PIE code gen work fine on Linux but not Debian? (It passes all the 32 bit tests on the autotester.)Hello, D programs compiled with 32-bit DMD are not working. I compiled with dmd and also tested rdmd using version 2.086.0-0 for both 32-bit and the 64-bit with -m32 directive, and it didn't work. I also tested the nightly version I downloaded today and the execution continues to print "segmentation fault (core dumped)". The same error does NOT occur when using LDC.This unfortunately is a well-known issue: https://issues.dlang.org/show_bug.cgi?id=19116 tl;dr: use LDC. It's better maintained, faster, has support for tons of architectures etc. Alternatively, you could also switch to ld.gold which you probably want to do anyhow if you can (faster link times!) or x86_64.
Nov 01 2019
On Saturday, 2 November 2019 at 00:04:27 UTC, Walter Bright wrote:Why does the PIE code gen work fine on Linux but not Debian? (It passes all the 32 bit tests on the autotester.)GCC 6 enabled PIE by default, you have to disable it manually with `-no-pie`. The auto-tester uses and ancient GCC version which is not affected.
Nov 02 2019
On 11/2/2019 10:06 AM, Suleyman wrote:On Saturday, 2 November 2019 at 00:04:27 UTC, Walter Bright wrote:Yes, but I'd like to know exactly what code sequence generated by dmd is not working, vs what ldc is generating that does work.Why does the PIE code gen work fine on Linux but not Debian? (It passes all the 32 bit tests on the autotester.)GCC 6 enabled PIE by default, you have to disable it manually with `-no-pie`. The auto-tester uses and ancient GCC version which is not affected.
Nov 02 2019
On Sunday, 3 November 2019 at 04:36:50 UTC, Walter Bright wrote:On 11/2/2019 10:06 AM, Suleyman wrote:There is nothing wrong with DMD, the problem is in the coordination with the linker. For example: ``` extern(C): void printf(const char*, ...); int g = 10; void main() { printf("OK\n"); int i = g; // crash printf("%d\n", i); } ``` Note: compile the program with -betterC to avoid linking druntime. This program crashes, but if you add the -fPIC switch it works. LDC has -fPIC by default.On Saturday, 2 November 2019 at 00:04:27 UTC, Walter Bright wrote:Yes, but I'd like to know exactly what code sequence generated by dmd is not working, vs what ldc is generating that does work.Why does the PIE code gen work fine on Linux but not Debian? (It passes all the 32 bit tests on the autotester.)GCC 6 enabled PIE by default, you have to disable it manually with `-no-pie`. The auto-tester uses and ancient GCC version which is not affected.
Nov 03 2019
On Friday, 1 November 2019 at 23:03:23 UTC, Seb wrote:tl;dr: use LDC. It's better maintained,How many people are maintaining LDC in comparison to DMD?
Nov 02 2019
On Sunday, 3 November 2019 at 00:15:29 UTC, Exil wrote:On Friday, 1 November 2019 at 23:03:23 UTC, Seb wrote:That wouldn't be a fair question because frontend development is backend agnostic, and the backend of LDC is a separate project project LLVM.tl;dr: use LDC. It's better maintained,How many people are maintaining LDC in comparison to DMD?
Nov 02 2019
On Sunday, 3 November 2019 at 04:34:18 UTC, Suleyman wrote:On Sunday, 3 November 2019 at 00:15:29 UTC, Exil wrote:Those kinds of decisions are in part what affect the maintainability of a project, so it would be a fair assessment to include.On Friday, 1 November 2019 at 23:03:23 UTC, Seb wrote:That wouldn't be a fair question because frontend development is backend agnostic, and the backend of LDC is a separate project project LLVM.tl;dr: use LDC. It's better maintained,How many people are maintaining LDC in comparison to DMD?
Nov 03 2019
On Sunday, 3 November 2019 at 18:35:41 UTC, Exil wrote:Let's just say it's a lot less than LLVM maintainers. Usually the backend just works but we could use some more backend contributors. Translating the backend from C to D was a step in the right direction, but it still looks like C. Maybe it can be modernized. But Walter has a pile of more important work at all levels, language, frontend, and backend, so lesser the dependence on Walter is except for getting approval the more can be achieved in parallel.[...]Those kinds of decisions are in part what affect the maintainability of a project, so it would be a fair assessment to include.
Nov 03 2019
On Sunday, 3 November 2019 at 19:28:41 UTC, Suleyman wrote:On Sunday, 3 November 2019 at 18:35:41 UTC, Exil wrote:LLVM developers don't work specifically on LDC do they?Let's just say it's a lot less than LLVM maintainers.[...]Those kinds of decisions are in part what affect the maintainability of a project, so it would be a fair assessment to include.Usually the backend just works but we could use some more backend contributors.It doesn't for me, I come across quite a few bugs due to the backend.Translating the backend from C to D was a step in the right direction, but it still looks like C. Maybe it can be modernized. But Walter has a pile of more important work at all levels, language, frontend, and backend, so lesser the dependence on Walter is except for getting approval the more can be achieved in parallel.Modernizing isnt the issue. Wouldn't you agree that LLVM has the absolute least dependence on Walter :)? All arguments you've made are all basically why LDC is the better option than anything that could be done with a custom backend. Its just a waste of resources, and the quality of LDC in comparison to DMD speaks volumes, especially when you consider LDC is maintained mostly by a single individual.
Nov 04 2019
On Tue, Nov 05, 2019 at 02:55:58AM +0000, Exil via Digitalmars-d wrote:On Sunday, 3 November 2019 at 19:28:41 UTC, Suleyman wrote:[...]For the past several releases now, LDC has been closely tracking the latest DMD releases. If codegen quality is important to you, just use LDC instead. You won't miss much at all. I've been considering to do that myself as well (in fact, one of my projects now defaults to LDC, and it may well be that I'll start using LDC by default sometime in the near future). I really only use DMD for one-off script-like programs and for Phobos bugfixing these days, or where performance isn't a top priority. I've repeated many times that DMD consistently produces binaries that run 20-30% slower than binaries produced by LDC (for CPU-intensive tasks). So where performance or codegen quality is an issue, I recommend just using LDC completely. It's not so easy to convince Walter to give up the backend that he's been working on for decades. :-D And he doesn't really need to since we have LDC, and LDC has been closely tracking DMD releases so staying up-to-date with latest D developments isn't even a big issue anymore. (LDC's frontend is identical to DMD's so there's no difference there.) T -- Everybody talks about it, but nobody does anything about it! -- Mark TwainTranslating the backend from C to D was a step in the right direction, but it still looks like C. Maybe it can be modernized. But Walter has a pile of more important work at all levels, language, frontend, and backend, so lesser the dependence on Walter is except for getting approval the more can be achieved in parallel.Modernizing isnt the issue. Wouldn't you agree that LLVM has the absolute least dependence on Walter :)? All arguments you've made are all basically why LDC is the better option than anything that could be done with a custom backend. Its just a waste of resources, and the quality of LDC in comparison to DMD speaks volumes, especially when you consider LDC is maintained mostly by a single individual.
Nov 04 2019
On Tuesday, 5 November 2019 at 06:38:24 UTC, H. S. Teoh wrote:It's not so easy to convince Walter to give up the backend that he's been working on for decades.dmd is still significantly faster to run and to recompile!DMD releases so staying up-to-date with latest D developments isn't even a big issue anymore. (LDC's frontend is identical to DMD's so there's no difference there.)That's not quite true. They share about 98% of the code, but that remaining 2% can be significant at times. For example, ldc's extern(Objective-C) lacks much of the stuff dmd's have, since that's part of that 2% glue code that is compiler specific.
Nov 05 2019
On Tuesday, 5 November 2019 at 12:11:24 UTC, Adam D. Ruppe wrote:dmd is still significantly faster to runWithout `-O -release`, otherwise LDC is usually faster.and to recompile!Depends on what you are working on. If it's just the frontend, then recompilation should take exactly as much time as DMD with appropriate settings. If it's just a .cpp file, then it's fast as well; if it's a C++ header file included by many .cpp's, then it can take some time.The glue code is much more than e.g. gluelayer.d and objc_glue.d; at its core, LDC and GDC are glue code, translating the frontend's AST to the LLVM/gcc intermediate representation. It doesn't help that DMD's source tree doesn't clearly separate frontend and glue code (which includes e2ir.d, s2ir.d etc.).(LDC's frontend is identical to DMD's so there's no difference there.)That's not quite true. They share about 98% of the code, but that remaining 2% can be significant at times.
Nov 05 2019
On Tuesday, 5 November 2019 at 13:32:22 UTC, kinke wrote:Without `-O -release`, otherwise LDC is usually faster.Sorry, should have been `-O -inline`.
Nov 05 2019
On Tuesday, 5 November 2019 at 13:32:22 UTC, kinke wrote:On Tuesday, 5 November 2019 at 12:11:24 UTC, Adam D. RuppeTo roughly quantize that (I got interested myself), counting lines of code with scc [1], in the ldc src dir: scc dmd (frontend): 127,960 LOC scc driver gen ir: 37,136 LOC So the ratio isn't 98:2, but rather something like 77.5:22.5, which is quite a difference. [1] https://github.com/boyter/sccThey share about 98% of the code, but that remaining 2% can be significant at times.The glue code is much more [...]
Nov 05 2019
On Tuesday, 5 November 2019 at 12:11:24 UTC, Adam D. Ruppe wrote:On Tuesday, 5 November 2019 at 06:38:24 UTC, H. S. Teoh wrote:If that's truly important it can be done with LLVM. Jai uses LLVM and compiles significantly faster than D.It's not so easy to convince Walter to give up the backend that he's been working on for decades.dmd is still significantly faster to run and to recompile!
Nov 05 2019
On Wednesday, 6 November 2019 at 03:13:46 UTC, Exil wrote:On Tuesday, 5 November 2019 at 12:11:24 UTC, Adam D. Ruppe wrote:How do you know how fast Jai compiles? I thought it hadn't been released yet? Been waiting what seems like years to try it out.On Tuesday, 5 November 2019 at 06:38:24 UTC, H. S. Teoh wrote:If that's truly important it can be done with LLVM. Jai uses LLVM and compiles significantly faster than D.It's not so easy to convince Walter to give up the backend that he's been working on for decades.dmd is still significantly faster to run and to recompile!
Nov 05 2019
On Wednesday, 6 November 2019 at 06:01:31 UTC, Jonathan Marler wrote:How do you know how fast Jai compiles? I thought it hadn't been released yet? Been waiting what seems like years to try it out.When I spoke to Jonathan Blow in person about Jai a couple of years back, he was quite open about performance and issues surrounding what he was doing. I'd be inclined to take him at his word when he talks about speed here.
Nov 06 2019
On Wednesday, 6 November 2019 at 08:33:44 UTC, Ethan wrote:On Wednesday, 6 November 2019 at 06:01:31 UTC, Jonathan Marler wrote:He said it compiles significantly faster than D?How do you know how fast Jai compiles? I thought it hadn't been released yet? Been waiting what seems like years to try it out.When I spoke to Jonathan Blow in person about Jai a couple of years back, he was quite open about performance and issues surrounding what he was doing. I'd be inclined to take him at his word when he talks about speed here.
Nov 06 2019
On Wednesday, 6 November 2019 at 08:38:12 UTC, Jonathan Marler wrote:He said it compiles significantly faster than D?Not to me. But it's not hard to write equivalent code to his examples in D and get your own times to compare to his. If you compile on similar hardware, you'll get a good idea. I'd also expect his compile-time code execution engine to be in a better state that DMD's CTFE engine is currently (but Stefan is working on fixing that).
Nov 06 2019
On Wednesday, 6 November 2019 at 09:17:42 UTC, Ethan wrote:On Wednesday, 6 November 2019 at 08:38:12 UTC, Jonathan Marler wrote:He's building a game with Jai that compile in under a second. Small examples aren't indicative of how fast a compiler can compile when projects start getting larger. D isn't fast even with smaller examples if you include the wrong standard library modules.He said it compiles significantly faster than D?Not to me. But it's not hard to write equivalent code to his examples in D and get your own times to compare to his. If you compile on similar hardware, you'll get a good idea.I'd also expect his compile-time code execution engine to be in a better state that DMD's CTFE engine is currently (but Stefan is working on fixing that)."New CTFE" has been a WIP for years. I did take a look at it a while back and I'm not surprised it's taking so long to implement. It might very well be a few more years before it gets completed, and I can see it being really unstable when it does eventually get to that point.
Nov 06 2019