Closed Bug 1443823 Opened 7 years ago Closed 6 years ago

undefined reference to `__imp_mozalloc_abort' error in MinGW x64

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox-esr60 --- fixed
firefox62 --- fixed

People

(Reporter: tjr, Assigned: tjr)

References

Details

(Whiteboard: [tor])

Attachments

(1 file)

>  /builds/worker/workspace/build/src/obj-firefox/_virtualenv/bin/python /builds/worker/workspace/build/src/config/expandlibs_exec.py --uselist --  /builds/worker/workspace/build/src/sccache2/sccache /builds/worker/workspace/build/src/mingw32/bin/x86_64-w64-mingw32-g++ -mwindows -shared -Wl,--gc-sections -Wl,--out-implib > -Wl,libcrashinjectdll.a -o crashinjectdll.dll crashinjectdll.o ./module.res -lpthread -Wl,--build-id -static /builds/worker/workspace/build/src/build/win32/crashinjectdll/crashinjectdll.def        -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32
>  Executing: ../../../../sccache2/sccache ../../../../mingw32/bin/x86_64-w64-mingw32-g++ -mwindows -shared -Wl,--gc-sections -Wl,--out-implib -Wl,libcrashinjectdll.a -o crashinjectdll.dll /builds/worker/workspace/build/src/obj-firefox/build/win32/crashinjectdll/tmpAKUgnN.list module.res -lpthread -Wl,--build-id -static ../../../../build> /win32/crashinjectdll/crashinjectdll.def -luuid -lgdi32 -lwinmm -lwsock32 -luserenv -lsecur32
>  /builds/worker/workspace/build/src/obj-firefox/build/win32/crashinjectdll/tmpAKUgnN.list:
>      INPUT("crashinjectdll.o")
>  crashinjectdll.o: In function `__throw_bad_exception':
>  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/throw_gcc.h:53: undefined reference to `__imp_mozalloc_abort'
>  crashinjectdll.o: In function `__throw_bad_alloc':
>  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/throw_gcc.h:59: undefined reference to `__imp_mozalloc_abort'
>  crashinjectdll.o: In function `__throw_bad_cast':
>  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/throw_gcc.h:65: undefined reference to `__imp_mozalloc_abort'
>  crashinjectdll.o: In function `__throw_bad_typeid':
>  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/throw_gcc.h:71: undefined reference to `__imp_mozalloc_abort'
>  crashinjectdll.o: In function `__throw_bad_function_call':
>  /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/throw_gcc.h:78: undefined reference to `__imp_mozalloc_abort'
>  crashinjectdll.o:/builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/throw_gcc.h:84: more undefined references to `__imp_mozalloc_abort' follow
>  collect2: error: ld returned 1 exit status
>  /builds/worker/workspace/build/src/config/rules.mk:699: recipe for target 'crashinjectdll.dll' failed
>  make[4]: *** [crashinjectdll.dll] Error 1


crashinjectdll.o is trying import like so:

> nm crashinjectdll.o  | grep alloc_abort
>                 U __imp_mozalloc_abort

However it's exported like so:

> nm mozalloc_abort.o  | grep alloc_abort
> 0000000000000000 p .pdata$_Z14mozalloc_abortPKc
> 0000000000000000 t .text$_Z14mozalloc_abortPKc
> 0000000000000000 r .xdata$_Z14mozalloc_abortPKc
> 0000000000000000 T _Z14mozalloc_abortPKc

This looks like an extern C thing maybe?  Jacek do you have any thoughts?
Flags: needinfo?(jacek)
It indeed looks like extern C thing, although I don't see how crashinjectdll.o would try to import it as extern C. It uses MFBT_API in declaration, which is just dllimport/dllexport thing.

Anyway, does adding MOZ_EXTERN_C to mozalloc_abort.h so that we also export it as extern C help?
Flags: needinfo?(jacek)
Found the issue. I'm not sure if mstackrealign is needed on x64 - Jacek?
Great, nice catch! Ideally, we should not need mstackrealign. We needed it for x86 because GCC assumed aligned stack while MSVC didn't. I think that on x64 both compilers assume stack align (although I'm not 100% sure).

Looking at the patch, I'd suggest to move mstackrealign to be set around line 859 since it's not arch-specific.
Blocks: 1448749
Comment on attachment 8961926 [details]
Bug 1443823 Apply no-keep-inline-dllexport to MinGW x64 also

https://reviewboard.mozilla.org/r/230752/#review236864

::: js/src/old-configure.in:817
(Diff revision 1)
> +        elif test -n "$GNU_CC"; then
> +            CFLAGS="$CFLAGS -mstackrealign -fno-keep-inline-dllexport"
> +            CXXFLAGS="$CXXFLAGS -mstackrealign -fno-keep-inline-dllexport"

It would be better to just move that out of the per-cpu-type checks.
Attachment #8961926 - Flags: review?(mh+mozilla)
Comment on attachment 8961926 [details]
Bug 1443823 Apply no-keep-inline-dllexport to MinGW x64 also

https://reviewboard.mozilla.org/r/230752/#review238598
Attachment #8961926 - Flags: review?(mh+mozilla) → review+
After some fair amount of bisecting on the weekend it turns out that this patch fixes bug 1392604 as well. It's not obvious to me yet why that's the case. Thus, I wonder if that fact alone could at least get mentioned in the commit message of this patch. I might help others to save some bisecting/debugging time in the future.
Comment on attachment 8961926 [details]
Bug 1443823 Apply no-keep-inline-dllexport to MinGW x64 also

[Approval Request Comment]

This is one of several MinGW Build patches I'd like to land in esr60 for Tor. It will prevent them from carrying their own patches for the lifetime of esr60 and will enable us to keep the MinGW build functioning and know if/when/how it was broken by new commits into esr60.

This commit only affects the MinGW build configuration, so it is low-risk.
Attachment #8961926 - Flags: approval-mozilla-esr60?
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/cab870519a15
Apply no-keep-inline-dllexport to MinGW x64 also r=glandium
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/cab870519a15
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Comment on attachment 8961926 [details]
Bug 1443823 Apply no-keep-inline-dllexport to MinGW x64 also

mingw build fix, approved for 60.1esr
Attachment #8961926 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
See Also: → 1548624
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: