Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Merge with 2.065 Release #76

Merged
merged 2 commits into from
Jun 11, 2014
Merged

Merge with 2.065 Release #76

merged 2 commits into from
Jun 11, 2014

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Apr 21, 2014

It's a round-about time we start to get this done.

This PR does the following:

  • Merges the D-frontend up until dlang/dmd@d098e5c
  • Switches over toIR to a visitor interface.
  • Merges the D-frontend up until dlang/dmd@4c5b9c2
  • Migrates D intrinsics into a .def file.
  • Finishes up the rest of the merges with the front-end sources as provided by the 2.065 release.

Also renames the last of the .c files over to .cc - however we can't drop the separation between .glue.o and .cglue.o just yet. There's still one big conflict between GCC and the D front-end that is optimize being a macro in GCC, and a common method in D frontend.

Subsequently I'll praise the day when optimize either becomes a visitor or we switch the front-end over to D.

From here on afterwards (this includes 2.066) @yebblies gets quite prolific in his changes, and it's hard to keep a track of anything that is going on.

Things on the TODO list before 2.065 2.066 merge is complete:

  • Rename glue sources using the new proposed scheme.
  • Rewrite d-toir.cc as a visitor. Done in 2.065
  • Remove dfrontend/builtins.c and re-implement in the glue. Done in 2.065
  • Migrate D intrinsic routines to a .def file. Done in 2.065
  • Maybe migrate D library routines to a .def file.
  • Maybe remove dfrontend/cppmangle.c and integrate in the glue layer.
  • For all new files re-written, document extensively!!!

So, only a couple hundred thousand LOC to write. ;o)

@yebblies
Copy link

:)

@ibuclaw
Copy link
Member Author

ibuclaw commented May 4, 2014

Simply converting toIR into a visitor is taking a long time alone because:

  1. Updating code conventions to match those for C++ (now that there are standards laid out).
  2. Documenting the code extensively.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 1, 2014

@yebblies - ibuclaw@865f7e8

IIRC the rest of 2.065 should be easy... in the sense that the next 1K lines of code changes will be done by someone else and not me.

Hurrah!

@yebblies
Copy link

yebblies commented Jun 1, 2014

Well, at least it reduces the frontend diff.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 1, 2014

It also reduces complexity of glue. Wasn't too nice handling things in 3 different places (1 in front end, 2 in glue)

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 2, 2014

Hmm... it would be nice if the ARM/Float unittests were clearly marked. ie: at the top of modified files, there is the following stock message:

NOTE: This file has been patched from the original DMD distribution to
work with the GDC compiler.

Which is a good visual indicator to tell me whether or not this file can be copied across without any manual intervention / hand merging. Rather than me hand merging everything just incase there's a commented out / tweaked unittest.

@jpf91
Copy link
Contributor

jpf91 commented Jun 2, 2014

I'll make sure to include such messages in the future. I think I have upstreamed most of these changes, but probably not in time for 2.065.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 3, 2014

OK, with 9a809df everything builds.

Now time to merge in the testsuite + run unittests / fix regressions.

@ibuclaw ibuclaw changed the title Merge with 2.065 pre-release development Merge with 2.065 Release Jun 3, 2014
@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 5, 2014

@yebblies I apologise in advance for any PRs and re-opening bugs that I may do. I've just looked at the test suite results and it's not pretty. :o)

The worst part is tracking down what bug is tied to which change.

@yebblies
Copy link

yebblies commented Jun 6, 2014

PRs against dmd? I'll be watching.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 8, 2014

OK, x86_64 unittests now pass, and so does the testsuite with the exception to 2 unresolved tests regarding what may appear to be C++ linking problems.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 8, 2014

OK - almost done. Just need some platform testing now.

@jpf91 - could you try this on ARM? I'm currently getting X32 sorted out.

@jpf91
Copy link
Contributor

jpf91 commented Jun 8, 2014

Awesome! I'll run the tests on ARM but it'll take some time (i.e. days) ;-)

@jpf91
Copy link
Contributor

jpf91 commented Jun 9, 2014

The version in gcc.version needs to be updated, void_node was added 2014-05-21.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 9, 2014

OK - can you make sure that you've got 821b671 applied too, one NRVO bug slipped through the cracks. Dynamic array comparison should be better optimized too.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 9, 2014

@jpf91 - Pushed into master 879968a

@jpf91
Copy link
Contributor

jpf91 commented Jun 9, 2014

Thanks. I get this error when compiling:

../../gcc-4.10-20140608/gcc/d/d-decls.cc: In member function ‘Symbol* FuncDeclaration::toThunkSymbol(int)’:
../../gcc-4.10-20140608/gcc/d/d-decls.cc:536:38: error: lvalue required as left operand of assignment
       DECL_COMDAT_GROUP (thunk_decl) = DECL_COMDAT_GROUP (target_func_decl);

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 9, 2014

Probably serves me right for using gcc.git on an "inbetween snapshot" revision - I'll update and fix master accordingly.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 9, 2014

Actually, wait, I've just looked again at your error:

../../gcc-4.10-20140608

I'm yet to switch to that snapshot date. I'd imagine there's been updates I'm not aware of yet.

@jpf91
Copy link
Contributor

jpf91 commented Jun 10, 2014

Just checked, it also happens with gcc-4.10-20140525

@jpf91
Copy link
Contributor

jpf91 commented Jun 10, 2014

gcc-4.10-20140525 doesn't compile on ARM (a gcc bug), but I see you updated to 20140608 which should work...

druntime is missing an declaration for ARM, I'll file an upstream pull request:

diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
index 52c4f70..ad87e1c 100644
--- a/libphobos/libdruntime/core/stdc/fenv.d
+++ b/libphobos/libdruntime/core/stdc/fenv.d
@@ -75,6 +75,16 @@ else version( linux )

         alias fexcept_t = ushort;
     }
+    // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/arm/bits/fenv.h;hb=HEAD
+    else version (ARM)
+    {
+        struct fenv_t
+        {
+            uint __cw;
+        }
+
+        alias fexcept_t = uint;
+    }
     else
     {
         static assert(0, "Unimplemented architecture");

@jpf91
Copy link
Contributor

jpf91 commented Jun 10, 2014

UNRESOLVED: runnable/gdc.d compilation failed to produce executable
UNRESOLVED: runnable/gdc.d -g  compilation failed to produce executable
UNRESOLVED: runnable/testcontracts.d compilation failed to produce executable
UNRESOLVED: runnable/testcontracts.d -g  compilation failed to produce executable
UNRESOLVED: runnable/testcontracts.d -finline-functions  compilation failed to produce executable
UNRESOLVED: runnable/testcontracts.d -g -finline-functions  compilation failed to produce executable
UNRESOLVED: runnable/testprofile.d compilation failed to produce executable
UNRESOLVED: runnable/testprofile.d -g  compilation failed to produce executable
UNRESOLVED: runnable/testsafe.d compilation failed to produce executable
FAIL: runnable/gdc.d (internal compiler error)
FAIL: runnable/gdc.d -g  (internal compiler error)
FAIL: runnable/testcontracts.d (internal compiler error)
FAIL: runnable/testcontracts.d -g  (internal compiler error)
FAIL: runnable/testcontracts.d -finline-functions  (internal compiler error)
FAIL: runnable/testcontracts.d -g -finline-functions  (internal compiler error)
FAIL: runnable/testprofile.d (internal compiler error)
FAIL: runnable/testprofile.d -g  (internal compiler error)
FAIL: runnable/testsafe.d (internal compiler error)
FAIL: runnable/xtest46.d execution test
FAIL: runnable/xtest46.d -g  execution test
FAIL: runnable/xtest46.d -O2  execution test
FAIL: runnable/xtest46.d -g -O2  execution test

All UNRESOLVED and most FAIL tests seem to have one common cause, gdc always segfaults:

spawn /home/jpf/build/objdir/gcc/testsuite/gdc/../../gdc -B/home/jpf/build/objdir/gcc/testsuite/gdc/../../ runnable/testsafe.d -fno-diagnostics-show-caret -fdiagnostics-color=never -I/home/jpf/build/objdir/armv7l-unknown-linux-gnueabihf/./libphobos/libdruntime -I/home/jpf/build/objdir/armv7l-unknown-linux-gnueabihf/./libphobos/libdruntime/import -I/home/jpf/build/objdir/armv7l-unknown-linux-gnueabihf/./libphobos/libdruntime/armv7l-unknown-linux-gnueabihf -I/home/jpf/build/gcc-4.10-20140608/gcc/testsuite/../../libphobos/src -I/home/jpf/build/gcc-4.10-20140608/gcc/testsuite/../../libphobos/libdruntime -I/home/jpf/build/gcc-4.10-20140608/gcc/testsuite/gdc.test/runnable -I/home/jpf/build/gcc-4.10-20140608/gcc/testsuite/gdc.test/runnable/imports -L/home/jpf/build/objdir/armv7l-unknown-linux-gnueabihf/./libphobos/src -lm -o ./testsafe.exe
runnable/testsafe.d: In member function 'test':
runnable/testsafe.d:434: internal compiler error: Segmentation fault
0x68b36b crash_signal
    ../../gcc-4.10-20140608/gcc/toplev.c:337
0x70f537 get_chain_decl
    ../../gcc-4.10-20140608/gcc/tree-nested.c:334
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://bugzilla.gdcproject.org> for instructions.
compiler exited with status 1
output is:
runnable/testsafe.d: In member function 'test':
runnable/testsafe.d:434: internal compiler error: Segmentation fault
0x68b36b crash_signal
    ../../gcc-4.10-20140608/gcc/toplev.c:337
0x70f537 get_chain_decl
    ../../gcc-4.10-20140608/gcc/tree-nested.c:334
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://bugzilla.gdcproject.org> for instructions.

FAIL: runnable/testsafe.d (internal compiler error)

I'll try to get a better backtrace tomorrow.

There's also one evaluation order thing but it doesn't look ARM specific at a first glance?

core.exception.AssertError@runnable/xtest46.d(2083): cdabe
----------------
0x493cf onAssertErrorMsg
    ../../../../gcc-4.10-20140608/libphobos/libdruntime/core/exception.d:432
0x1603f void xtest46.test100()

unittest results are mixed. There's only one new 'failing' test, but it's a segmentation fault.

This patch needs to be applied anyway:

diff --git a/libphobos/src/std/conv.d b/libphobos/src/std/conv.d
index a3c6d96..708a14a 100644
--- a/libphobos/src/std/conv.d
+++ b/libphobos/src/std/conv.d
@@ -2715,7 +2715,7 @@ unittest
 //Tests for the double implementation
 unittest
 {
-    import core.stdc.stdlib;
+    import core.stdc.stdlib, std.math;
     static if(real.mant_dig == 53)
     {
         //Should be parsed exactly: 53 bit mantissa
diff --git a/libphobos/src/std/variant.d b/libphobos/src/std/variant.d
index e17757d..2970bc5 100644
--- a/libphobos/src/std/variant.d
+++ b/libphobos/src/std/variant.d
@@ -1438,9 +1438,9 @@ unittest
     assert( v.get!(string) == "Hello, World!" );

     // Literal arrays are dynamically-typed
-    v = cast(int[5]) [1,2,3,4,5];
-    assert( v.peek!(int[5]) );
-    assert( v.get!(int[5]) == [1,2,3,4,5] );
+    v = cast(int[4]) [1,2,3,4];
+    assert( v.peek!(int[4]) );
+    assert( v.get!(int[4]) == [1,2,3,4] );

     {
         // @@@BUG@@@: array literals should have type T[], not T[5] (I guess)

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 10, 2014

@jpf91 your right, something has happened on gcc side between 28/05 and the 08/06 that is causing these tests to ICE.

And yep, that xtest46.d failure is not ARM specific. It was there to fix test5749 in the same file. (See d_build_call: creating a SAVE_EXPR for the 'object' parameter if it has side effects). Fixed.

sigh - too many things are volatile.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 10, 2014

As for the ICE's they were caused by the fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53927

tree-nested.c has always been a pain. From the time we had (broken) STATIC_CHAIN_EXPR and STATIC_CHAIN_DECL. To the time when I (eventually) fixed the nuance of it in 02f086f to the time I removed setting DECL_STATIC_CHAIN to prevent tree-nested.c from doing precisely what this ICE is doing 2d6aa22. To now when tree-nested.c is now setting DECL_STATIC_CHAIN on it's own accord then dying.

Actually, the fact that the middle-end is setting DECL_STATIC_CHAIN more an optimisation bug than anything else (bad codegen creating two chains - one by the frontend, the other by the backend).

The actual ICE itself is because of nested 'in' contracts. In this example GCC has no idea how to call the 'in' contract for interface I from class C. (Because the decl->parent hierarchy provided by the D front-end is a bit convoluted when it comes to contracts).

interface I
{
    void ice() in { }
}

class C : I
{
    void ice () in { }
    body { }
}

As all what the pass for tree-nested.c is doing is simply creating a static_chain_decl and reconstructing all nesting functions to use that decl as passed by a hidden parameter (this is already done by the front-end) then unnesting the function. Perhaps we can skip over this entire riff-raff of constant breakages from tree-nested.c by simply unnesting functions ourselves - and in the worst case, remove the whole notion of DECL_CONTEXT from the frontend codegen, so effectively all functions are public.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 10, 2014

OK, fixed in 16be749

There is actually a little more work that can be done (some red commits will follow) but I'll wait till after the 2.065 merge to do that.

@jpf91 - I have rebased the last two commits in this PR, so your sources will need to be updated accordingly.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 11, 2014

@jpf91 I now get passes across the board now:

        === gdc tests ===

Schedule of variations:
    unix/-m64
    unix/-m32
    unix/-mx32

        === gdc Summary for unix/-m64 ===

# of expected passes        15320

        === gdc Summary for unix/-m32 ===

# of expected passes        15320

        === gdc Summary for unix/-mx32 ===

# of expected passes        15320

Only to fail compilation on unittests for libphobos:

../../../../libphobos/src/std/variant.d: In function ‘__unittestL1419_9’:
../../../../libphobos/src/std/variant.d:1441: error: conversion to non-scalar type requested

Oh wait.... that is a typo!

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 11, 2014

Also, strange error message for the operation given!

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 11, 2014

Rebased, confirmed passing unittests and testsuite here.

@jpf91
Copy link
Contributor

jpf91 commented Jun 11, 2014

I looks like it should work fine on ARM now. (I guess you intentionally didn't include the fenv.d changes).

The tests which failed before ran fine, the segfault in the phobos unittest is gone and phobos tests pass [1]. Unfortunately I don't have the full results yet cause my PandaBoard locked up after runnable/testgc2. That's why I like the RaspberryPi that much, even if it's slow: The drivers / software stack is stable.

[1] except for math.internal.gammafunction, but that's nothing new

@etcimon
Copy link

etcimon commented Jun 11, 2014

I looks like it should work fine on ARM now. (I guess you intentionally didn't include the fenv.d changes).

Do you intend to release an RPM for the RapberryPi?

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 11, 2014

I looks like it should work fine on ARM now. (I guess you intentionally didn't include the fenv.d changes).

Oops, I must have missed that. Was originally waiting for you to raise a PR upstream. Then I fell asleep and forgot about it.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 11, 2014

OK - everything that I'm aware of needing merging in is merged in.

@jpf91 - Should I give you more time and let this sit tight till the weekend?

I might be able to crack out my trimslice and get testing on this.

@jpf91
Copy link
Contributor

jpf91 commented Jun 11, 2014

@ibuclaw no need to wait, I restarted the tests and they just finished.
All testsuite tests pass, unit tests as well so I think this is good to go :-)

@etcimon I'm not sure what you mean. We don't release distribution packages, that's a task for distribution packagers. I know debian/ubuntu will ship GDC on ARM and ArchlinuxARM also already ships GDC. But if you want to know whether we support the RaspberryPi: Yes, GDC should work just fine on the RPI. You can either build GDC from source or use our precompiled binaries.

@ibuclaw ibuclaw merged commit 54d27cc into D-Programming-GDC:master Jun 11, 2014
@ibuclaw ibuclaw deleted the 2.065 branch June 11, 2014 21:52
@jpf91
Copy link
Contributor

jpf91 commented Jun 12, 2014

@ibuclaw seems I found a bug/regression in gdc when building the mingw code:

struct IMAGEHLP_SYMBOL64
{
char[1] Name;
}

class StackTrace 
{
    char[][] resolveNoSync()
    {
        IMAGEHLP_SYMBOL64* symbol ;
        char[][] trace;
        if (*symbol.Name.ptr)
        uint disp;
        return trace;
    }
}
LANG=C /opt/gdc/bin/gdc test.d                                                                                                               :(
test.d: In member function 'resolveNoSync':
test.d:8: error: mismatching comparison operand types
char[1]
int
if (D.2571 != 0) goto <D.2572>; else goto <D.2573>;
test.d:8: internal compiler error: verify_gimple failed
0xa8e21f verify_gimple_in_seq(gimple_statement_base*)
    ../../gcc-4.9.0/gcc/tree-cfg.c:4609
0x8b85c1 gimplify_body(tree_node*, bool)
    ../../gcc-4.9.0/gcc/gimplify.c:8654
0x8b8956 gimplify_function_tree(tree_node*)
    ../../gcc-4.9.0/gcc/gimplify.c:8739
0x746707 analyze_function
    ../../gcc-4.9.0/gcc/cgraphunit.c:649
0x7479bb analyze_functions
    ../../gcc-4.9.0/gcc/cgraphunit.c:1017
0x7490b5 finalize_compilation_unit()
    ../../gcc-4.9.0/gcc/cgraphunit.c:2320
0x697567 d_finish_compilation(tree_node**, int)
    ../../gcc-4.9.0/gcc/d/d-objfile.cc:1941
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://bugzilla.gdcproject.org> for instructions.

I only tested this with gcc-4.9 (the backport is finished :-) but I'm currently building 4.10 to verify if the error happens there as well.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 12, 2014

I confirm this is a bug in 4.10 too. So must be codegen related.

This is the gcc codegen emitted (spot what is wrong :) if ((symbol)->Name != 0)
And the AST passed to gdc: if ((*symbol).Name)

I smell a front-end bug.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 12, 2014

@yebblies don't know if you can have a quick look into the above? The front-end appears to be doing some AST optimisation and passing us a type-punned char[1], rather than dereferencing the array like a good compiler. :o)

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 12, 2014

@jpf91 by the way, I swear I've seen something like this before, its some dejavu feeling from when venix1 did mingw maintenance a while back...

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 12, 2014

@jpf91
Copy link
Contributor

jpf91 commented Jun 12, 2014

Yes, seemed familiar to me as well ;-)

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 12, 2014

I blame @yebblies for this

dlang/dmd#2888

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 12, 2014

Raised a new bug https://issues.dlang.org/show_bug.cgi?id=12900

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants