-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
Thanks - how are the tests looking? |
Druntime is working pretty well but phobos is crashing for some reason. |
There probably is another problem with initialization/gc
Segfault:
|
src/rt/sections_ldc.d
Outdated
{ | ||
extern extern (C) __gshared | ||
extern (C) __gshared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was dropping the first extern
intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good catch! That's definitely wrong, as the symbols are left initialized with nulls, and the GC doesn't have a single global as GC root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More context: these symbols are to be provided by the linker. An extra underscore is prepended by LDC automatically.
src/rt/sections_ldc.d
Outdated
else version (Windows) | ||
{ | ||
pushRange(&_data_start__, &_bss_end__); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/msysgit/msys/blob/master/winsup/cygwin/winsup.h#L262. I think the previous code was correct - taking the address is necessary, and the old names should match as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and please don't touch the MSVC part in a functional way, that was working fine when 0.17 was released. ;) [You removed the extern
there too - thinking it was just a typo? extern(C) extern
would look better.]
Sorry my mistake but for some reason ldc is not adding that underscore.
Maybe someone more experienced will take care of the sections. |
Validating the symbols exist (and checking their mangled names via #include <stdio.h>
int global;
extern char _data_start__, _data_end__;
int main() {
printf("%p, %p, %p\n", &global, &_data_start__, &_data_end__);
return 0;
} |
|
Erm you're using clang? Please provide some more details about your environment, starting with Windows version, toolchain(s), used linker etc. |
I am using 64 bit mingw-w64 delivered by msys2(http://www.msys2.org/). GCC is producing same symbols as clang. |
You answered just one aspect - at least the linker would be good to know as well. For MSVC, those symbols are derived from the binary's headers at startup: https://github.com/ldc-developers/druntime/blob/ldc-ltsmaster/src/ldc/msvc.c. That file is currently excluded in |
Clang on mingw is not supporting MSVC's pragmas and also has different preprocessor defines. |
@wirx6 Those symbols are magic linker symbols, so the exact symbolnames that you need depend solely on the linker used. Perhaps because you are targeting mingw you have to use Linux-like linker magic symbolnames. These magic linker symbolnames are quite badly documented... so it's a bit of a pain to figure it out. http://www.airs.com/blog/archives/56 I see that in LDC master, we use a different mechanism to find the start and end of the data section. druntime/src/rt/sections_win64.d Line 80 in 822017a
Backporting that is an alternative path you can try. |
If you have a look at an old commit from before MSVC support was merged, data range registration was definitely working on mingw-w64. I don't quite remember everything that has changed since on Windows, though. |
7272731
to
f09bc42
Compare
@JohanEngelen I backported it and still getting the same error(I will leave it because it solves |
I just reluctantly installed MSYS2 and mingw-w64-x86_64-gcc. An additional leading underscore was needed (and not zero-initializing the global), then the symbols are there and seem plausible when linking with #include <stdio.h>
int global = 123;
extern char __data_start__, __data_end__;
int main() {
printf("%p, %p, %p\n", &global, &__data_start__, &__data_end__);
return 0;
}
On Win64, LDC doesn't prepend the C underscore for C symbols (Win32 only), so you'll need to declare it with 2 leading underscores in druntime. |
*add FILE definition *use ms's stdio functions *another try to fix sections *phobos will be fixed later
Thats what I got when added
So segfault happens somewhere there druntime/src/core/sys/windows/stacktrace.d Lines 398 to 409 in 9ec9ff4
|
Operator
Working:
Beside of this anything seems to be fine
|
I pushed a cleanup commit and verified the changes against current MinGW-w64 headers; should be fine except for [most likely irrelevant] stdin/out/err initialization (MinGW seems to use the normal MSVC infrastructure on Win64, but making ltsmaster use that for MinGW would be tedious and seems unnecessary). |
@wirx6: Please verify that it's still working like before, my MSYS environment isn't set up for building LDC. Will merge then. |
Got my environment to build now; druntime compiles fine. |
* add FILE definition * use ms's stdio functions * fix sections
No description provided.