www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Hacking on Phobos

reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
Hello all,

As per earlier discussion I'm trying to hack on Phobos to update the random 
sampling code.

To do this I've just copied random.d into a new file, randomsample.d, which I'm 
modifying and messing around with; I'm trying to build against a local copy of 
the GitHub Phobos sources.

When I try and compile,

    gdc -nophoboslib -I../phobos/ -o randomsample randomsample.d

I get a huge list of errors, beginning with:

/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 0 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 1 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 4 has invalid symbol index 10
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 5 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 6 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 7 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 8 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): 
relocation 9 has invalid symbol index 2

... and continuing on with a huge number of undefined reference errors.

To check if it was the source of the problem, I tried downloading and building
a 
local copy of the latest druntime, but the build process fails:

$ make -f posix.mak MODEL=64

[lots of successful stuff, followed by ...]

src/object_.d(237): Error: function object.TypeInfo.toHash of type  trusted 
ulong() overrides but is not covariant with object.Object.toHash of type
nothrow 
 trusted ulong()
src/object_.d(237): Error: function object.TypeInfo.toHash does not override
any 
function
src/object_.d(347): Error: function object.TypeInfo_Vector.getHash of type 
ulong(const(void*) p) overrides but is not covariant with 
object.TypeInfo.getHash of type nothrow  trusted ulong(const(void*) p)
src/object_.d(347): Error: function object.TypeInfo_Vector.getHash does not 
override any function

I can't find any easy or friendly "get started hacking on Phobos" page, so can 
anyone advise how to get set up correctly?

Thanks & best wishes,

     -- Joe
Apr 17 2012
next sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 17.04.2012 22:10, Joseph Rushton Wakeling wrote:
 Hello all,

 As per earlier discussion I'm trying to hack on Phobos to update the
 random sampling code.

 To do this I've just copied random.d into a new file, randomsample.d,
 which I'm modifying and messing around with; I'm trying to build against
 a local copy of the GitHub Phobos sources.

 When I try and compile,

 gdc -nophoboslib -I../phobos/ -o randomsample randomsample.d
First things first - development of phobos is done with dmd. Just because gdc is (logically so) somewhat behind dmd and new compiler features are still coming with every release. The process usually involves git cloning dmd, druntime and phobos. Then building all of them in the order of dmd, druntime, phobos. The the tricky part is replacing older binaries and library. After fresh cutting phobos edge builts make sure Phobos unittests all pass (make -fposix.mak unittest). I suggest to just modify phobos sources directly. It's DVCS after all so you always have a luxury of commit/revert. and rdmd --main -unittest /path/to/std/random.d works wonders in development cycle.
 Thanks & best wishes,

 -- Joe
-- Dmitry Olshansky
Apr 17 2012
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Tue, Apr 17, 2012 at 10:29:24PM +0400, Dmitry Olshansky wrote:
 On 17.04.2012 22:10, Joseph Rushton Wakeling wrote:
Hello all,

As per earlier discussion I'm trying to hack on Phobos to update the
random sampling code.

To do this I've just copied random.d into a new file, randomsample.d,
which I'm modifying and messing around with; I'm trying to build against
a local copy of the GitHub Phobos sources.

When I try and compile,

gdc -nophoboslib -I../phobos/ -o randomsample randomsample.d
First things first - development of phobos is done with dmd. Just because gdc is (logically so) somewhat behind dmd and new compiler features are still coming with every release. The process usually involves git cloning dmd, druntime and phobos. Then building all of them in the order of dmd, druntime, phobos. The the tricky part is replacing older binaries and library.
You can just edit /etc/dmd.conf to that effect (if it conflicts with your stable version of dmd, you could try to change the git dmd source to look for dmd.conf in a different place, say /usr/src/d-devel/dmd.conf or something, and so you can completely isolate the two installations).
 After fresh cutting phobos edge builts make sure Phobos unittests
 all pass (make -fposix.mak unittest).
 I suggest to just modify phobos sources directly. It's DVCS after
 all so you always have a luxury of commit/revert.
The convention is to create a branch for making changes, this way it's very easy to generate pull requests on github if you ever wanted to contribute your code to the official codebase. Branches are super-cheap in git anyway, and you can edit source files to your heart's content since you can easily switch back to master if you mess something up. T -- My program has no bugs! Only unintentional features...
Apr 17 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-04-17 20:47, H. S. Teoh wrote:

 You can just edit /etc/dmd.conf to that effect (if it conflicts with
 your stable version of dmd, you could try to change the git dmd source
 to look for dmd.conf in a different place, say /usr/src/d-devel/dmd.conf
 or something, and so you can completely isolate the two installations).
DVM can be use for this. Just clone dmd, druntime and phobos to <path> and then run "dvm compile <path>". It will compile all projects and setup a correct dmd.conf. -- /Jacob Carlborg
Apr 17 2012
prev sibling next sibling parent reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 17/04/12 20:29, Dmitry Olshansky wrote:
 First things first - development of phobos is done with dmd. Just because gdc
is
 (logically so) somewhat behind dmd and new compiler features are still coming
 with every release.
Fair enough. I've followed the instructions here: https://xtzgzorex.wordpress.com/2011/07/31/d-building-dmd-and-phobos-on-linux/
 I suggest to just modify phobos sources directly. It's DVCS after all so you
 always have a luxury of commit/revert.
I want to do some side-by-side tests of current and new, so it makes sense to just have a myrandom.d.
 and rdmd --main -unittest /path/to/std/random.d
 works wonders in development cycle.
Oddly enough building rdmd with my newly-build dmd results in error: rdmd.d(197): Error: function std.path.rel2abs!().rel2abs is deprecated /usr/local/include/d2/std/algorithm.d(4226): Error: template std.algorithm.endsWith does not match any function template declaration /usr/local/include/d2/std/algorithm.d(4184): Error: template std.algorithm.endsWith cannot deduce template function from argument types !("a == b")(string,string,string,string,string) /usr/local/include/d2/std/algorithm.d(4226): Error: template instance endsWith!("a == b") errors instantiating template /usr/local/include/d2/std/algorithm.d(4226): Error: template std.algorithm.endsWith does not match any function template declaration /usr/local/include/d2/std/algorithm.d(4184): Error: template std.algorithm.endsWith cannot deduce template function from argument types !("a == b")(string,string,string,string,string) /usr/local/include/d2/std/algorithm.d(4226): Error: template instance endsWith!("a == b") errors instantiating template /usr/local/include/d2/std/algorithm.d(4226): Error: template std.algorithm.endsWith does not match any function template declaration /usr/local/include/d2/std/algorithm.d(4184): Error: template std.algorithm.endsWith cannot deduce template function from argument types !("a == b")(string,string,string,string,string) /usr/local/include/d2/std/algorithm.d(4226): Error: template instance endsWith!("a == b") errors instantiating template /usr/local/include/d2/std/algorithm.d(4226): Error: template std.algorithm.endsWith does not match any function template declaration /usr/local/include/d2/std/algorithm.d(4184): Error: template std.algorithm.endsWith cannot deduce template function from argument types !("a == b")(string,string,string,string,string) /usr/local/include/d2/std/algorithm.d(4226): Error: template instance endsWith!("a == b") errors instantiating template /usr/local/include/d2/std/algorithm.d(4226): Error: template std.algorithm.endsWith does not match any function template declaration /usr/local/include/d2/std/algorithm.d(4184): Error: template std.algorithm.endsWith cannot deduce template function from argument types !("a == b")(string,string,string,string,string) /usr/local/include/d2/std/algorithm.d(4226): Error: template instance endsWith!("a == b") errors instantiating template
Apr 17 2012
next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 17.04.2012 23:27, Joseph Rushton Wakeling wrote:
 On 17/04/12 20:29, Dmitry Olshansky wrote:
 First things first - development of phobos is done with dmd. Just
 because gdc is
 (logically so) somewhat behind dmd and new compiler features are still
 coming
 with every release.
Fair enough. I've followed the instructions here: https://xtzgzorex.wordpress.com/2011/07/31/d-building-dmd-and-phobos-on-linux/
 I suggest to just modify phobos sources directly. It's DVCS after all
 so you
 always have a luxury of commit/revert.
I want to do some side-by-side tests of current and new, so it makes sense to just have a myrandom.d.
 and rdmd --main -unittest /path/to/std/random.d
 works wonders in development cycle.
Oddly enough building rdmd with my newly-build dmd results in error:
Just feed it -d switch ;) Still somebody has to step up and upgrade rdmd to use the new way of Phobos. -- Dmitry Olshansky
Apr 17 2012
prev sibling parent reply "Sergey Matveychuk" <sem semmy.ru> writes:
On Tuesday, 17 April 2012 at 19:28:05 UTC, Joseph Rushton 
Wakeling wrote:
 Oddly enough building rdmd with my newly-build dmd results in 
 error:

 rdmd.d(197): Error: function std.path.rel2abs!().rel2abs is 
 deprecated
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 std.algorithm.endsWith does not match any function template 
 declaration
 /usr/local/include/d2/std/algorithm.d(4184): Error: template 
 std.algorithm.endsWith cannot deduce template function from 
 argument types !("a == b")(string,string,string,string,string)
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 instance endsWith!("a == b") errors instantiating template
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 std.algorithm.endsWith does not match any function template 
 declaration
 /usr/local/include/d2/std/algorithm.d(4184): Error: template 
 std.algorithm.endsWith cannot deduce template function from 
 argument types !("a == b")(string,string,string,string,string)
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 instance endsWith!("a == b") errors instantiating template
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 std.algorithm.endsWith does not match any function template 
 declaration
 /usr/local/include/d2/std/algorithm.d(4184): Error: template 
 std.algorithm.endsWith cannot deduce template function from 
 argument types !("a == b")(string,string,string,string,string)
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 instance endsWith!("a == b") errors instantiating template
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 std.algorithm.endsWith does not match any function template 
 declaration
 /usr/local/include/d2/std/algorithm.d(4184): Error: template 
 std.algorithm.endsWith cannot deduce template function from 
 argument types !("a == b")(string,string,string,string,string)
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 instance endsWith!("a == b") errors instantiating template
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 std.algorithm.endsWith does not match any function template 
 declaration
 /usr/local/include/d2/std/algorithm.d(4184): Error: template 
 std.algorithm.endsWith cannot deduce template function from 
 argument types !("a == b")(string,string,string,string,string)
 /usr/local/include/d2/std/algorithm.d(4226): Error: template 
 instance endsWith!("a == b") errors instantiating template
The same problem here. Who can help?
Apr 28 2012
parent "David Nadlinger" <see klickverbot.at> writes:
On Saturday, 28 April 2012 at 18:46:16 UTC, Sergey Matveychuk 
wrote:
 On Tuesday, 17 April 2012 at 19:28:05 UTC, Joseph Rushton 
 Wakeling wrote:
 Oddly enough building rdmd with my newly-build dmd results in 
 error:

 rdmd.d(197): Error: function std.path.rel2abs!().rel2abs is 
 deprecated
 […]
The same problem here. Who can help?
rel2abs has been deprecated respectively renamed, use -d to compile. David
Apr 28 2012
prev sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 17/04/12 20:47, H. S. Teoh wrote:
 The convention is to create a branch for making changes, this way it's
 very easy to generate pull requests on github if you ever wanted to
 contribute your code to the official codebase. Branches are super-cheap
 in git anyway, and you can edit source files to your heart's content
 since you can easily switch back to master if you mess something up.
Yea, I know; normally I would, but I want to do some side-by-side tests of the new and old RandomSample class, and it seems like a PITA to have to go through checkout-compile-copy to /usr/local/lib/-etc.etc. to do comparisons. Yes, there are unittests and (once I compile rdmd successfully:-) I can probably use these, but in the short term it seems simpler to just make a new file containing the bits I need and tweak it there.
Apr 17 2012
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2012-04-17 20:10, Joseph Rushton Wakeling wrote:
 Hello all,

 As per earlier discussion I'm trying to hack on Phobos to update the
 random sampling code.

 To do this I've just copied random.d into a new file, randomsample.d,
 which I'm modifying and messing around with; I'm trying to build against
 a local copy of the GitHub Phobos sources.
This is how I'm compiling when developing on dmd, druntime or phobos. Create a new directory, <path>. Clone dmd, druntime and phobos to <path> from github: https://github.com/D-Programming-Language Download and install DVM: https://bitbucket.org/doob/dvm Run "dvm compile <path>". This will compile dmd, druntime and phobos and setup a correct dmd.conf file. The binary will be placed in <path>/dmd/bin<arch>, if I recall correctly. Then I create a build script, <path>/phobos/build.sh, looking something like this: dvm compile .. rdmd --compiler=../dmd/bin<arch>/dmd --build-only main.d "main.d" would be a test file I'm using. Then I just run "./build.sh" and it will build everything. main.d and build.sh can be added to <path>/phobos/.git/info/exclude to be ignored.
 I can't find any easy or friendly "get started hacking on Phobos" page,
 so can anyone advise how to get set up correctly?
I've thought about this several times, we need one badly. -- /Jacob Carlborg
Apr 18 2012
parent Somedude <lovelydear mailmetrash.com> writes:
Le 18/04/2012 12:04, Jacob Carlborg a écrit :
 
 I can't find any easy or friendly "get started hacking on Phobos" page,
 so can anyone advise how to get set up correctly?
I've thought about this several times, we need one badly.
I've just created a page in the Wiki with the posts here: http://prowiki.org/wiki4d/wiki.cgi?HackingPhobos I'm sure it's not perfect and can be improved upon, so feel free to contribute. The page is accessible from here: http://prowiki.org/wiki4d/wiki.cgi?DevelopmentWithD
Apr 18 2012