February 16, 2014
On Sunday, 16 February 2014 at 13:19:00 UTC, David Nadlinger wrote:

> Sorry, yes, I just intended to write "special section".
>
> But as a side note, Darwin's dyld is more or less alone in offering
> that functionality. On other OSes, DMD still uses bracketed sections
> for various tasks.

Yes, exactly. But where talking iOS and OS X here ;)

> I was thinking about that as well, yes. In theory, it should be
> possible to adapt the code in LLVM without too much of a hassle (I
> don't think there would be any problems with x86-specific relocations
> or so), but as I said, I haven't looked into how the TLS sections are
> emitted when writing to Mach-O at all.
>
> Another thing to keep in mind would be that we probably can't use some
> of the APIs due to App Store restrictions…

_dyld_register_func_for_add_image and other similar functions are documented here [1], which I assume means they are public API and are allowed to be used (I have not read the App Store license). But LDC already uses a function to iterate TLS data on OS X in the runtime (if its still is used) which not documented. Phobos also uses _NSGetEnviron which is not documented. The first could be replaced with some of these functions [1]. The second could perhaps be replaced with a C main function accepting the environment variables as a third parameter.

BTW, the _dyld_register_func_for_add_image is not safe to use with dynamic libraries, since it's not possible to unregister the callback. There is another undocumented function that can be used instead.

[1] https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html

--
/Jacob Carlborg

February 16, 2014
> For now, exception handling seems the most useful missing feature.  So I am looking at that.

I hacked in rudimentary SjLj exception handing code in the ldc/eh.d.  It is kind of ugly, but it works on my D test cases (tried all of the try/catch try/finally scope(exit) and friends, and RAII structs).  It should also allow cleanup handlers when C++ exceptions (foreign ex) bubble up, but haven't tested that yet.  Again, only testing on my iPhone 4 (armv7).  I will push up changes ios-2.064 branch after I make it less ugly.
-- 
Dan
February 17, 2014
Dan Olson <zans.is.for.cans@yahoo.com> writes:

>> For now, exception handling seems the most useful missing feature.  So I am looking at that.
>
> I hacked in rudimentary SjLj exception handing code in the ldc/eh.d.  It is kind of ugly, but it works on my D test cases (tried all of the try/catch try/finally scope(exit) and friends, and RAII structs).  It should also allow cleanup handlers when C++ exceptions (foreign ex) bubble up, but haven't tested that yet.

Nevermind on allowing foreign (i.e. c++) exceptions for now.  When I let
a c++ exception bubble up through D stack, scope(success) triggers
instead of scope(failure).  I see why now.  scope(failure) is
essentially a catch(Throwable e) throw(t) which isn't selected.  It
would be cool to make it work, but not important, so I'll put it aside.
However, D being a system language, it _could_ have a mechanism for
catching non-D exceptions that escape from another language.

David, a question.  I read https://github.com/ldc-developers/ldc/issues/489.

What is the symptom?  The iOS sjlj unwinder is different, but I'd like a test case to see.

https://www.opensource.apple.com/source/libunwind/libunwind-35.1/src/Unwind-sjlj.c
-- 
Dan
February 17, 2014
On 17 Feb 2014, at 18:04, Dan Olson wrote:
> David, a question.  I read
> https://github.com/ldc-developers/ldc/issues/489.
>
> What is the symptom?  The iOS sjlj unwinder is different, but I'd like a
> test case to see.

The ARM EABI (at least as far as the GCC runtime goes) doesn't use SLJL, but DWARF EH with a slightly different unwinding process.

I don't have reduced test cases for the remaining failures, unfortunately. It's just clear that EH is still not working correctly in all cases when running the Phobos test suite (you'll see crashes in _Unwind_RaiseException or related druntime abort()s).

David
February 18, 2014
"David Nadlinger" <code@klickverbot.at> writes:

> On 17 Feb 2014, at 18:04, Dan Olson wrote:
>> David, a question.  I read https://github.com/ldc-developers/ldc/issues/489.
>>
>> What is the symptom?  The iOS sjlj unwinder is different, but I'd
>> like a
>> test case to see.
>
> The ARM EABI (at least as far as the GCC runtime goes) doesn't use SLJL, but DWARF EH with a slightly different unwinding process.
>
> I don't have reduced test cases for the remaining failures, unfortunately. It's just clear that EH is still not working correctly in all cases when running the Phobos test suite (you'll see crashes in _Unwind_RaiseException or related druntime abort()s).
>

Hopefully when I run the phobos unittests in a day or two on iOS, can see if I run into anything related.  When you say Phobos test suite, do you just mean compiling phobos with -unittest and running all the unittest blocks?

I don't know a way to run a bunch of little unittest programs on iOS, so cooked up an approach that just bakes all unittests into one app.  Maybe there are better ways, if someone with iOS dev experience has some ideas, I'd like to know.

Recipe:
- Add -unittest to druntime library build flags.

- Have main program iterate over ModuleInfo, calling unitTest func if
   set.

- Link with flag -force_load libdruntime-ldc-debug.a to pull every obj
   file into exe.

33 unittests ran and passed.  Two failed because they don't compile with -unittest flag.  I will have to take an inventory because a simple grep of druntime counts 38 files with 'unittest'.

thread.d fails to compile because I didn't finish fiber support for iOS,

and then this wierd one:

/Users/dan/projects/ldc/ldc-git/runtime/druntime/src/rt/aaA.d(565): Error: Function type does not match previously declared function with the same mangled name: _d_assocarrayliteralTX

-- 
Dan

February 26, 2014
On Tuesday, 18 February 2014 at 08:24:30 UTC, Dan Olson wrote:
> "David Nadlinger" <code@klickverbot.at> writes:
>
>> On 17 Feb 2014, at 18:04, Dan Olson wrote:
>>> David, a question.  I read
>>> https://github.com/ldc-developers/ldc/issues/489.
>>>
>>> What is the symptom?  The iOS sjlj unwinder is different, but I'd
>>> like a
>>> test case to see.
>>
>> The ARM EABI (at least as far as the GCC runtime goes) doesn't use
>> SLJL, but DWARF EH with a slightly different unwinding process.
>>
>> I don't have reduced test cases for the remaining failures,
>> unfortunately. It's just clear that EH is still not working correctly
>> in all cases when running the Phobos test suite (you'll see crashes in
>> _Unwind_RaiseException or related druntime abort()s).
>>
>
> Hopefully when I run the phobos unittests in a day or two on iOS, can
> see if I run into anything related.  When you say Phobos test suite, do
> you just mean compiling phobos with -unittest and running all the
> unittest blocks?
>
> I don't know a way to run a bunch of little unittest programs on iOS, so
> cooked up an approach that just bakes all unittests into one app.  Maybe
> there are better ways, if someone with iOS dev experience has some
> ideas, I'd like to know.
>
> Recipe:
> - Add -unittest to druntime library build flags.
>
> - Have main program iterate over ModuleInfo, calling unitTest func if
>    set.
>
> - Link with flag -force_load libdruntime-ldc-debug.a to pull every obj
>    file into exe.
>
> 33 unittests ran and passed.  Two failed because they don't compile with
> -unittest flag.  I will have to take an inventory because a simple grep
> of druntime counts 38 files with 'unittest'.
>
> thread.d fails to compile because I didn't finish fiber support for iOS,
>
> and then this wierd one:
>
> /Users/dan/projects/ldc/ldc-git/runtime/druntime/src/rt/aaA.d(565): Error: Function type does not match previously declared function with the same mangled name: _d_assocarrayliteralTX

This is one of the release blocking bugs. Please just ignore for now.

Regards,
Kai
February 27, 2014
"Kai Nacke" <kai@redstar.de> writes:

> On Tuesday, 18 February 2014 at 08:24:30 UTC, Dan Olson wrote:
>> /Users/dan/projects/ldc/ldc-git/runtime/druntime/src/rt/aaA.d(565): Error: Function type does not match previously declared function with the same mangled name: _d_assocarrayliteralTX
>
> This is one of the release blocking bugs. Please just ignore for now.
>
> Regards,
> Kai

Ok, thanks.  I have enough other unittest failures to keep me busy. Many are floating point comparson related, I am guessing because of cross compiling from x64 to arm.  Some are memory corruption, I think due to gc not setup correctly.  They go away when I disable GC.  The sjlj exception handling for arm/iOS is working, that is encouraging.

My iOS phobos/druntime unittest tally so far is:

67 pass
15 fail
5   not run (compiler error with -unittest option)
February 27, 2014
On Thursday, 27 February 2014 at 08:13:00 UTC, Dan Olson wrote:
> "Kai Nacke" <kai@redstar.de> writes:
>
>> On Tuesday, 18 February 2014 at 08:24:30 UTC, Dan Olson wrote:
>>> /Users/dan/projects/ldc/ldc-git/runtime/druntime/src/rt/aaA.d(565):
>>> Error: Function type does not match previously declared function
>>> with the same mangled name: _d_assocarrayliteralTX
>>
>> This is one of the release blocking bugs. Please just ignore for now.
>>
>> Regards,
>> Kai
>
> Ok, thanks.  I have enough other unittest failures to keep me busy.
> Many are floating point comparson related, I am guessing because of
> cross compiling from x64 to arm.  Some are memory corruption, I think
> due to gc not setup correctly.  They go away when I disable GC.
>  The
> sjlj exception handling for arm/iOS is working, that is encouraging.
>
> My iOS phobos/druntime unittest tally so far is:
>
> 67 pass
> 15 fail
> 5   not run (compiler error with -unittest option)

This is really encouraging, I really appreciate every effort you've made!
February 27, 2014
On Thursday, 27 February 2014 at 13:16:25 UTC, ElvisZhou wrote:
> On Thursday, 27 February 2014 at 08:13:00 UTC, Dan Olson wrote:
>> "Kai Nacke" <kai@redstar.de> writes:
>>
>>> On Tuesday, 18 February 2014 at 08:24:30 UTC, Dan Olson wrote:
>>>> /Users/dan/projects/ldc/ldc-git/runtime/druntime/src/rt/aaA.d(565):
>>>> Error: Function type does not match previously declared function
>>>> with the same mangled name: _d_assocarrayliteralTX
>>>
>>> This is one of the release blocking bugs. Please just ignore for now.
>>>
>>> Regards,
>>> Kai
>>
>> Ok, thanks.  I have enough other unittest failures to keep me busy.
>> Many are floating point comparson related, I am guessing because of
>> cross compiling from x64 to arm.  Some are memory corruption, I think
>> due to gc not setup correctly.  They go away when I disable GC.
>> The
>> sjlj exception handling for arm/iOS is working, that is encouraging.
>>
>> My iOS phobos/druntime unittest tally so far is:
>>
>> 67 pass
>> 15 fail
>> 5   not run (compiler error with -unittest option)
>
> This is really encouraging, I really appreciate every effort you've made!

+1 !

I always get goosebumps when this thread shows unread posts ;)

February 27, 2014
On 26 Feb 2014, at 19:11, Kai Nacke wrote:
> On Tuesday, 18 February 2014 at 08:24:30 UTC, Dan Olson wrote:
>> /Users/dan/projects/ldc/ldc-git/runtime/druntime/src/rt/aaA.d(565): Error: Function type does not match previously declared function with the same mangled name: _d_assocarrayliteralTX
>
> This is one of the release blocking bugs. Please just ignore for now.

It's obviously your choice, but I'm not sure whether this should actually be a release-blocking bug or if it would make more sense to just comment out that unit test (IIRC there are some commented out already) and ignore the mismatch until we start work on full-LTO builds.

David