www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D2 and FreeBSD

reply Marco Righele <marco_righele yahoo.it> writes:
Greetings,
Are there any plans for a FreeBSD release of the D2 DMD compiler ?

Marco
Aug 03 2010
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
Marco Righele wrote:
 Greetings,
 Are there any plans for a FreeBSD release of the D2 DMD compiler ?
Yes, it's just that there hasn't been much interest in it yet.
Aug 03 2010
prev sibling parent reply Shin Fujishiro <rsinfu gmail.com> writes:
Marco Righele <marco_righele yahoo.it> wrote:
 Greetings,
 Are there any plans for a FreeBSD release of the D2 DMD compiler ?
I'm using DMD v2 on my FreeBSD box with these patches: - FreeBSD patches for druntime. http://d.puremagic.com/issues/show_bug.cgi?id=3528 - [FreeBSD] real constants are rounded to double precision http://d.puremagic.com/issues/show_bug.cgi?id=4191 - [FreeBSD] imprecision in decimal floating-point literals http://d.puremagic.com/issues/show_bug.cgi?id=4198 Please vote up! ;-) Shin
Aug 03 2010
next sibling parent reply Marco Righele <marco_righele yahoo.it> writes:
On 08/04/10 07:47, Shin Fujishiro wrote:
 Marco Righele <marco_righele yahoo.it> wrote:
 Greetings,
 Are there any plans for a FreeBSD release of the D2 DMD compiler ?
I'm using DMD v2 on my FreeBSD box with these patches: - FreeBSD patches for druntime. http://d.puremagic.com/issues/show_bug.cgi?id=3528 - [FreeBSD] real constants are rounded to double precision http://d.puremagic.com/issues/show_bug.cgi?id=4191 - [FreeBSD] imprecision in decimal floating-point literals http://d.puremagic.com/issues/show_bug.cgi?id=4198
Thanks, I didn't realize that the zip comes with the full source :D. The patches apply cleanly, but I found number of issues though. (The DMD version I used is 2.047, the one downloadable from the site, while my box is running FreeBSD 8.1/x86) When compiling dmd, the linker complains about missing C++ symbols. Changing the linker from gcc to g++ in freebsd.mak seemed to solve the problem. When compiling druntime, a static assertion triggers during linking: src/rt/llmath.d(286): Error: static assert (0x1p+63L == 0x1p+52L) is false gmake: *** [lib/libdruntime.a] Error 1 Finally I was unable to compile phobos, as I encountered errors in different modules, including references to freebsd related files that aren't in the zip I downloaded. Am I supposed to use a different version of the compiler/libraries ? If so, is it publicly available ?
 Please vote up! ;-)
Will do ! :)
 
 
 Shin
Marco
Aug 04 2010
next sibling parent Marco Righele <marco_righele yahoo.it> writes:
On 08/04/10 12:30, Marco Righele wrote:

 Finally I was unable to compile phobos, as I encountered errors in
 different modules, including references to freebsd related files that
 aren't in the zip I downloaded.
 Am I supposed to use a different version of the compiler/libraries ?
 If so, is it publicly available ?
 
 
Silly me, the sources are on dsource.org :). I downloaded the latest trunk of phobos, and tried to compile if The compilation gave the following error:
 gmake -f posix.mak
std/math.d(1304): Error: shift by -48 is outside the range 0..32 std/math.d(1305): Error: template instance 'floatTraits!(real)' is not a variable std/math.d(1306): Error: template instance 'floatTraits!(real)' is not a variable gmake[1]: *** [generated/posix/release/libphobos2.a] Error 1 gmake: *** [release] Error 2 For the time being I just commented the offending function and completed the compilation. In the end I was able to obtain the executable and the libraries. Configuring the paths to the imports of phobos and druntime in dmd.conf, adapting the one provided in the binary package for linux
 cat /etc/dmd.conf
[Environment] DFLAGS=-I/opt/phobos -I/opt/druntime/import -L -L/usr/lib I'm able to compile an hello world, but not to link it
 dmd hello.d
/usr/bin/ld: : No such file: No such file or directory collect2: ld returned 1 exit status --- errorlevel 1 Given that others are using it without problems I think it's because I made some mistakes somewhere, but where ? Any pointer to documentation or mail on how to build it would be appreciated, thanks, Marco
Aug 04 2010
prev sibling parent reply Shin Fujishiro <rsinfu gmail.com> writes:
Marco Righele <marco_righele yahoo.it> wrote:
 Thanks, I didn't realize that the zip comes with the full source :D.
 The patches apply cleanly, but I found number of issues though.
 
 (The DMD version I used is 2.047, the one downloadable from the site,
 while my box is running FreeBSD 8.1/x86)
Thanks for testing! By the way, how did you apply the patches? You might need to set an -l option to deal with recent newline changes in dmd source: .../dmd2/src/dmd/src% patch -l -p2 < 4191.patch .../dmd2/src/dmd/src% patch -l -p1 < 4198.patch
 When compiling dmd, the linker complains about missing C++ symbols.
 Changing the linker from gcc to g++ in freebsd.mak seemed to solve
 the problem.
Hmm... that's strange. I haven't got such an error. I'm sorry but I can't tell what's going wrong. I could build dmd 2.047 as follows: -------------------- % mkdir 2.047 % cd 2.047 % fetch http://ftp.digitalmars.com/dmd.2.047.zip % unzip dmd.2.047.zip % cd dmd2/src/dmd/src % fetch -o 4191.patch 'http://d.puremagic.com/issues/attachment.cgi?id=629' % fetch -o 4198.patch 'http://d.puremagic.com/issues/attachment.cgi?id=632' % patch -l -p2 < 4191.patch % patch -l -p1 < 4198.patch % gmake -f freebsd.mak % cp dmd ~/bin -------------------- Compiler is gcc 4.2.1 on FreeBSD/i386 8-STABLE. Does this work for you?
 When compiling druntime, a static assertion triggers during linking:
 
 src/rt/llmath.d(286): Error: static assert  (0x1p+63L == 0x1p+52L) is false
 gmake: *** [lib/libdruntime.a] Error 1
I'm not sure, but you might be using a non-patched version accidentally. Have you copied the newly-built dmd executable to, for example, ~/bin? I built druntime with the patched dmd 2.047: -------------------- % cd 2.047/dmd2/src/druntime % fetch -o 3528.patch 'http://d.puremagic.com/issues/attachment.cgi?id=703' % patch -l -p0 < 3528.patch % gmake -f posix.mak --------------------
 Finally I was unable to compile phobos, as I encountered errors in
 different modules, including references to freebsd related files that
 aren't in the zip I downloaded.
The following file is not in the release zip. Please download it: http://svn.dsource.org/projects/phobos/trunk/phobos/std/c/freebsd/socket.d And here's a quick-hacked FreeBSD makefile that I use: http://gist.github.com/508638 I could build Phobos with the following command lines: -------------------- % cd 2.047/dmd2/src/phobos % mkdir std/c/freebsd % fetch -o std/c/freebsd/socket.d 'http://svn.dsource.org/projects/phobos/trunk/phobos/std/c/freebsd/socket.d' % fetch -o my-freebsd.mak 'http://gist.github.com/raw/508638/b4f85e2de4f41a22a09fb895aa48b7a62fefb71e/my-freebsd.mak' % gmake -f my-freebsd.mak --------------------
 Am I supposed to use a different version of the compiler/libraries ?
The patches should be valid for recent few releases including 2.047. I may be wrong though...
 If so, is it publicly available ?
Compiler and libraries are under open source. :-) http://www.dsource.org/projects/dmd/ http://www.dsource.org/projects/druntime/ http://www.dsource.org/projects/phobos/ I'm tracking these repositories with git-svn. Shin
Aug 04 2010
next sibling parent Marco Righele <marco_righele yahoo.it> writes:
Hi Shin, thanks for you time and patience

On 08/04/10 22:43, Shin Fujishiro wrote:
 Compiler is gcc 4.2.1 on FreeBSD/i386 8-STABLE.  Does this work for you?
I should have checked earlier. I didn't realize that I was using a different version of gcc off of /opt. Removing it and using the stock one removed all the compilation issues. The linking problem was due to a wrong configuration of dmd.conf with a lone "-L" that caused ld to receive an empty argument. Now I'm able to compile and run my test programs. Thanks a lot ! Marco
Aug 05 2010
prev sibling parent reply Juergen Lock <nox FreeBSD.org> writes:
On 08/04/2010 22:43, Shin Fujishiro wrote:
 Marco Righele<marco_righele yahoo.it>  wrote:
[...]
 I could build dmd 2.047 as follows:
 --------------------
 % mkdir 2.047
 % cd 2.047
 % fetch http://ftp.digitalmars.com/dmd.2.047.zip
 % unzip dmd.2.047.zip
 % cd dmd2/src/dmd/src
 % fetch -o 4191.patch 'http://d.puremagic.com/issues/attachment.cgi?id=629'
 % fetch -o 4198.patch 'http://d.puremagic.com/issues/attachment.cgi?id=632'
 % patch -l -p2<  4191.patch
 % patch -l -p1<  4198.patch
 % gmake -f freebsd.mak
 % cp dmd ~/bin
 --------------------
 Compiler is gcc 4.2.1 on FreeBSD/i386 8-STABLE.  Does this work for you?


 When compiling druntime, a static assertion triggers during linking:

 src/rt/llmath.d(286): Error: static assert  (0x1p+63L == 0x1p+52L) is false
 gmake: *** [lib/libdruntime.a] Error 1
I'm not sure, but you might be using a non-patched version accidentally. Have you copied the newly-built dmd executable to, for example, ~/bin? I built druntime with the patched dmd 2.047: -------------------- % cd 2.047/dmd2/src/druntime % fetch -o 3528.patch 'http://d.puremagic.com/issues/attachment.cgi?id=703' % patch -l -p0< 3528.patch % gmake -f posix.mak --------------------
 Finally I was unable to compile phobos, as I encountered errors in
 different modules, including references to freebsd related files that
 aren't in the zip I downloaded.
The following file is not in the release zip. Please download it: http://svn.dsource.org/projects/phobos/trunk/phobos/std/c/freebsd/socket.d And here's a quick-hacked FreeBSD makefile that I use: http://gist.github.com/508638 I could build Phobos with the following command lines: -------------------- % cd 2.047/dmd2/src/phobos % mkdir std/c/freebsd % fetch -o std/c/freebsd/socket.d 'http://svn.dsource.org/projects/phobos/trunk/phobos/std/c/freebsd/socket.d' % fetch -o my-freebsd.mak 'http://gist.github.com/raw/508638/b4f85e2de4f41a22a09fb895aa48b7a62fefb71e/my-freebsd.mak' % gmake -f my-freebsd.mak --------------------
 Am I supposed to use a different version of the compiler/libraries ?
The patches should be valid for recent few releases including 2.047. I may be wrong though... [...]
For the record, here is what I had to change for dmd 2.048: - 4191.patch and 3528.patch are no longer needed (already applied) - modfl() was missing in src/druntime/src/core/stdc/math.d only for FreeBSD with a comment "// nontrivial conversion", adding it back _seems_ to work according to quick tests (was the problem that real * i.e. long double * wasn't working properly for C bindings in earlier versions and the FreeBSD bindings just hadn't been updated yet?) I've put the patch here: http://people.freebsd.org/~nox/tmp/d/dmd.2.048-druntime-modfl.patch - (at least) std.concurrency and std.exception need to be added to my-freebsd.mak, I've put that patch here: http://people.freebsd.org/~nox/tmp/d/dmd.2.048-phobos-myfreebsdmak.patch ====== And wrt debugging: I tested both gdb head (checked out after the D patches went in) and Doug Rabson's D-aware debugger ngdb which he annouced as a 'Technology Preview' here: http://lists.freebsd.org/pipermail/freebsd-current/2009-August/011071.html ..and I found two things: a) gdb still chokes on dmd -g debug symbols because the D DWARF extensions conflict with DWARF-4: http://d.puremagic.com/issues/show_bug.cgi?id=4180 disabling the DW_TAG_type_unit case in gdb/dwarf2read.c at least makes it no longer complain: http://people.freebsd.org/~nox/tmp/d/d-gdb-dwarf2read.c.patch b) both debuggers treat arrays as unsigned long long (like main()'s standard string[] args) - at least ngdb prints them correctly if I do a manual cast: (ngdb) p *cast(char [][] *)&args I then looked at the debug symbols using readelf -w and found it's actually dmd's fault not the debugger's, the array really seems to be marked as the unsigned long long type: <1><a4>: Abbrev Number: 3 (DW_TAG_base_type) DW_AT_name : unsigned long long DW_AT_byte_size : 8 DW_AT_encoding : 7 (unsigned) .. <2><516>: Abbrev Number: 5 (DW_TAG_formal_parameter) DW_AT_name : args DW_AT_type : <a4> DW_AT_location : 2 byte block: 91 8 (DW_OP_fbreg: 8) Any chance this can be changed? :) (I suspect this is a DWARF-only problem i.e. it `works on Windows'?) ====== And finally, I've generated liblzma bindings using bcd, adjusted them for D2, http://people.freebsd.org/~nox/tmp/d/lzma.d (sorry about the httpd treating .d as application/octet-stream) - and then made a small threaded .xz compression hack to try out D2, http://people.freebsd.org/~nox/tmp/d/xzj.d This is very much a WIP but can already be used to compress files or stdin to another file or stdout (so it can be used in pipes and with tar's --use-compress-program), using all cores. Binaries at: http://people.freebsd.org/~nox/tmp/d/freebsd8/xzj http://people.freebsd.org/~nox/tmp/d/linux/xzj (both i386 of course) Run with -h for a small usage message and see the source for more info. Comments are welcome, also if anyone wants to test/port it to non-FreeBSD/Linux and/or check if the lzma bindings are OK... Also, should I submit the bindings somewhere? I checked the struct sizes and they matched: http://people.freebsd.org/~nox/tmp/d/lzmastructsizes-c.c http://people.freebsd.org/~nox/tmp/d/lzmastructsizes.d These are direct C bindings only tho i.e. I did not make a wrapper class like std.zlib... Ok so that's it for now, cheers, Juergen PS: I've meanwhile found another WIP threaded .xz compressor written in C, but it is specific to tarfiles (it even indexes them and can extract a single file quickly), and it uses a private branch(?) of liblzma: http://github.com/vasi/pixz http://github.com/vinzenz/liblzma
Sep 11 2010
next sibling parent reply Brad Roberts <braddr puremagic.com> writes:
On 9/11/2010 11:25 AM, Juergen Lock wrote:

<snip lots of good info about dmd and freebsd>

Assuming you don't want these to get lost, you really ought to file bugzilla
entries for them.  Posts in a newsgroup/mailing list are a great way to have
them lost in the noise and to time.

Later,
Brad
Sep 11 2010
parent Juergen Lock <nox FreeBSD.org> writes:
On 09/12/2010 05:54, Brad Roberts wrote:
 On 9/11/2010 11:25 AM, Juergen Lock wrote:

 <snip lots of good info about dmd and freebsd>

 Assuming you don't want these to get lost, you really ought to file bugzilla
 entries for them.  Posts in a newsgroup/mailing list are a great way to have
 them lost in the noise and to time.
Done: modfl() missing for FreeBSD: http://d.puremagic.com/issues/show_bug.cgi?id=4862 DWARF debug symbols treat arrays as unsigned long long: http://d.puremagic.com/issues/show_bug.cgi?id=4863
Sep 13 2010
prev sibling parent Juergen Lock <nox FreeBSD.org> writes:
On 09/11/2010 20:25, I wrote:
 [...]
 And finally, I've generated liblzma bindings using bcd, adjusted them
 for D2,

 http://people.freebsd.org/~nox/tmp/d/lzma.d

 (sorry about the httpd treating .d as application/octet-stream) - and
Fixed now (the httpd.)
 then made a small threaded .xz compression hack to try out D2,

 http://people.freebsd.org/~nox/tmp/d/xzj.d

 This is very much a WIP but can already be used to compress
 files or stdin to another file or stdout (so it can be used in
 pipes and with tar's --use-compress-program), using all cores.
 Binaries at:

 http://people.freebsd.org/~nox/tmp/d/freebsd8/xzj
 http://people.freebsd.org/~nox/tmp/d/linux/xzj

 (both i386 of course) Run with -h for a small usage message
 and see the source for more info.

 Comments are welcome, also if anyone wants to test/port it to
 non-FreeBSD/Linux and/or check if the lzma bindings are OK...
 Also, should I submit the bindings somewhere? I checked the
 struct sizes and they matched:

 http://people.freebsd.org/~nox/tmp/d/lzmastructsizes-c.c
 http://people.freebsd.org/~nox/tmp/d/lzmastructsizes.d

 These are direct C bindings only tho i.e. I did not make a wrapper
 class like std.zlib...

 Ok so that's it for now, cheers,
 Juergen

 PS: I've meanwhile found another WIP threaded .xz compressor written
 in C, but it is specific to tarfiles (it even indexes them and can
 extract a single file quickly), and it uses a private branch(?)
 of liblzma:

 http://github.com/vasi/pixz
 http://github.com/vinzenz/liblzma
..and turns out pixz is not really using a private branch of liblzma but just an old version of it (that still has lzma_index_init() taking two args and that also still has lzma_index_record().)
Sep 13 2010
prev sibling parent Sohgo Takeuchi <sohgo sohgo.dyndns.org> writes:
From: Shin Fujishiro <rsinfu gmail.com>
|
 Marco Righele <marco_righele yahoo.it> wrote:
 Greetings,
 Are there any plans for a FreeBSD release of the D2 DMD compiler ?
I'm using DMD v2 on my FreeBSD box with these patches:
I also have used DMD2 on a FreeBSD 8 box for several month. I hope that these paches will be applied to the trunk. -- Sohgo Takeuchi
Aug 04 2010