goshawk / gdc
gdc development reloaded. This repo aims to continue the development of the gdc compiler
Status
D2: WORKING - 2.015. Tested on GCC 4.3.4.
D1: WORKING - 1.043. Tested on GCC-4.1.2 and GCC 4.3.1. GCC 4.3.2 - GCC 4.3.4 not working.
Support
To get support, you can access irc chat in irc.freenode.net channel #d.gdc
Mailing list will be set up soon.
Consider also to follow us on identi.ca microblogging at group dlanguage http://identi.ca/group/dlanguage
Build Instructions
Run these commands in a terminal:
hg clone https://goshawk@bitbucket.org/goshawk/gdc
mkdir gdc/dev
Grab GCC 4.3.4 sources from a mirror Unpack the GCC archive in the gdc/dev dir. This creates gdc/dev/gcc-4.3.4. Run these commands:
cd gdc/dev/gcc-4.3.4
ln -s ../../../d gcc/d
./gcc/d/setup-gcc.sh
mkdir objdir
cd objdir
../configure --enable-languages=d --disable-multilib --disable-shared
make
DESTDIR=/opt make install
export PATH=$PATH:/opt/usr/local/bin/
This will configure for a gdc D2 build, if you want D1 just add --d-language-version=1 to ./gcc/d/setup-gcc.sh command. The make command will perform the build. the make install command will install the compiled gdc in DESTDIR directory.
With last line, DESTDIR=/opt make install you will install gdc in /opt so it will not mess up with the installed gcc. Go in /opt to find the gdc executable.
With this source structure it will be easy to do modifications of the sources. To do changes, just modify files in gdc/d directory, it will be visible by the gcc sources. The objdir directory is used for configuration so that the gcc sources remains unmodified.
After that you follow the instructions you can do the following:
goshawk@jupiter:/$ gdc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --enable-languages=d --disable-multilib --disable-shared Thread model: posix gcc version 4.3.4 (GCC) goshawk@jupiter:/$ gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --enable-languages=d --disable-multilib --disable-shared Thread model: posix gcc version 4.3.4 (GCC)
As you can see you will start using the newly compiled gcc and gdc, overriding but not deleting the system default.
If you do changes in the code please submit an issue with a patch attached.
How to update gdc to a newer dmd frontend (= language version)
Here is a letter from David Friedman in how to merge the dmd compiler and the phobos library:
1. Extract the new dmd-xxx.zip package. 2. Diff the compiler source from the previously merged dmd version (not gdc's d/dmd or d/dmd2 directory). You may have to fix line endings in he new dmd source to get a clean diff. 3. Depending on the nature of the changes, it may be possible to simply apply the changes to the gdc version as a patch. Otherwise, make changes manually. Because some of the changes I made a pretty drastic, it will probably be easier to applies these incremental changes to gdc rather than try to re-apply my changes to the original dmd code. 4. Get the new compiler working and run regression tests. 5. Do steps 2 and 3 for Phobos. It helps to work on the compiler and Phobos separately. Sometimes compiler changes will require the new runtime library to work correctly, however. Also, I don't merge too many versions at a time. For example, I would probably do 2.015, 2.016+2.017, and then 2.018. The array operations in 2.018 should well tested before moving on. I don't really have any other documentation. I do have some scripts to help with the diffing process. David
You can find all the dmd and phobos versions in in the digitalmars ftp
To better perform a readable diff you can use this command
diff -Naruw dmdX dmdX+1 > dmdX-to-dmdX+1.patch
Where X is a dmd version.
To apply the generated patch in the most automatic way run patch as follows in the corresponding dmd or phobos dir
patch -p4 -l -F 3 --verbose < dmdX-to-dmdX+1.patch
It will patch all the files it can, and will place all the statement that can't be merged in file.rej where file is a filename.
If you have access to the Repository, read the RepositoryGuidelines before committing.
How to update gdc to a newer gcc
I've mailed David to know which are the steps he used to update to a newer version of gcc, this is the answer.
The first thing to do is modify d/setup-gcc.sh to allow building with the new version. Next, you should try to apply the set of patches in d/patches/ for the previous version. For the top-level-xxx patch, just manually apply the changes to Makefile.def and configure.ac. You will need to get the autogen package to rebuild Makefile.in. Rebuilding the top-level 'configure' script with autoconf may be tricky, so you just apply the one-line change directly to 'configure'. You probably will need to create a d-bi-attrs-44.h. This is select portion of gcc/c-common.c modified to for D. (Conditionally) included it in d-builtins.c. Most of the work is then getting GDC to work correctly. Any changes you make that are version specific should probably involve the use of the D_GCC_VER macro. Search for "D_GCC_VER" to get a feel for what you will need to do. Once you gotten everything working and are done making changes to the GCC sources, you need to create a set of patches for the new version. The for FSF GCC, there are two patches: One is the top-level, 'patch-toplev-<version>'. The other is for thee gcc/ directory 'patch-gcc-<version>'.
Gcc documentation
Gcc is a complex framework but there are good tutorials to learn its internals and to create a front end. This documents are useful if you want to collaborate in the gdc development.
