Linker problems with arm-wince, need help/info
pedro.alves at domatica.pt
Sun Jun 18 04:45:30 PDT 2006
Chad J wrote:
> pedro alves wrote:
>> That being said, are can try adding a
>> -fno-leading-underscore to TARGET_LIBGCC2_CFLAGS in
> Note that I cannot use cegcc's gcc, since it is based off of 4.1.x gcc
> which is not compatible with gdc.
It should be possible to apply cegcc's patches to gcc 4.0 though. I
started development against 4.0 and when I moved to 4.1 almost nothing
I guess at some point you will want to move to 4.1 or 4.2, though.
> Also, -fno-leading-underscore is used by the specfile I am using in
> this compiler. So it's been in use, how much so I am unsure of
> though. In fact, I'll attach my specfile since that may help things.
> First thing I did was download and install the cegcc binutils. I got
> them from the file downloads on the berliOS site. I then
> recompiled/reinstalled arm-wince-pe-gdc with the new binutils, and
> with -fno-leading-underscore inserted in TARGET_LIBGCC2_CFLAGS.
> Using my old crt0.o file in this configuration led to the same old
> Using a crt0.o I grabbed off of the cegcc-0.0.2 cygwin binaries
> yielded these errors:
> /tmp/cc7BG4tk.o:main.d:(.text+0x44): undefined reference to
> /tmp/cc7BG4tk.o:main.d:(.text+0x8c): undefined reference to
> /tmp/cc7BG4tk.o:main.d:(.data+0x40): undefined reference to
> undefined reference to `main2'
Old stuff. :) There was once a -Dmain=main2. It is now gone in recent
> Then I noticed where the crt0.S file that made that crt0.o file came
> from, and I found that in the cegcc-0.0.3 sources and tried to
> assemble that, but the assembler gave me an error:
> crt0.S: Assembler messages:
> crt0.S:24: Error: bad instruction `func_start __EH_HANDLER__'
The 'S' (uppercase) suffix means the file should be preprocessed before
being assembled. func_start is a macro.
> hmmm, so I changed that line to what it was in my startfile. Then it
> assembled fine, but when I used this new startfile I get the following
> /tmp/ccCPaYXV.o:main.d:(.text+0x44): undefined reference to
> /tmp/ccCPaYXV.o:main.d:(.text+0x8c): undefined reference to
> /tmp/ccCPaYXV.o:main.d:(.data+0x40): undefined reference to
> undefined reference to `__set_runtime_thread_mode'
> undefined reference to `main'
> Since the spec file seems to override the builtin stuff, I tried
> removing -fno-leading-underscore from my specfile to see what would
> happen, and it gives many more errors on compilation. I'm guessing
> the -fno-leading-underscore is fairly essential, or the resultant
> programs wouldn't be able to do essential things like talk to the
> WinCE OS/API, whose name manglings would have different underscoring.
"on compilation"? You mean on linking, right?
Lets ignore the __set_runtime_thread_mode, since you are not using a
recent cegcc runtime, where that function lives.
Ok. looks like those D function calls are somehow being emitted with an
Who inserts the unscore in _D3std4file5writeFAaAvZv? Is it the D
mangling that requires it?
Or could it be that the -fno-leading-underscore is being ignored by the
Are you really sure these functions are defined?
Isn't your 'main' being D mangled? I don't almost nothing D, just an
observer, but, isn't there an extern "C" equivalent required
around your main function? I guess there will be an extern "C" main that
initializes phobos and then calls a _Dmain, or whatever.
Where is this extern "C" main?
In recent cegcc, there is a default main in -lc that ld sucks in if the
the app doesn't define one. In Mamaich's toolchain, it is the other way
around, a default WinMain would call main.
I don't get why that isn't being found by ld. Did you build that cdllimp
with gcc4, or is it exactly the same from Mamaich? That would be
it was built against gcc 3.x.
> Concerning a somewhat unrelated problem, I wonder if there is a way to
> make something happen without an external specfile, that is, build it
> into the compiler: I want it to include fixincl.h, but only for C and
> C plus plus compilation. I tried putting this in
> TARGET_LIBGCC2_CFLAGS, but that messes up assembly :)
> The reason I ask is this would save a nasty hack I have to do. As it
> is, the make of gcc/gdc will fail when it gets to phobos because it
> tries to compile C files for arm-wince, but since it lacks the correct
> include info it fails. So I made a dummy compiler that calls the real
> compiler and tells it to include fixincl.h. Once make fails at
> phobos, I have to repeatedly replace xgcc with my own xgcc until the
> thing works (some motor skills and not-too-fast computer required!).
What are the contents of this fixincl.h? Doesn't phobos have something
like a config.h where you can make this changes?
To be able to include wince sdk files with gcc I use a scheme of:
I guess the fixincl.h name in this case is just a coincidence :)
More information about the D.gnu