use of undeclared identifier '_Unwind_Backtrace'

RESOLVED FIXED in mozilla17

Status

()

Core
XPCOM
RESOLVED FIXED
5 years ago
3 years ago

People

(Reporter: Jan Beich, Assigned: Jan Beich)

Tracking

Trunk
mozilla17
All
FreeBSD
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
User Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Firefox/17.0
Build ID: 20120809002637

Steps to reproduce:

1. Installed libunwind
2. Tried to compile firefox with gcc42 or clang.


Actual results:

xpcom/base/nsStackWalk.cpp:1197:29: error: use of undeclared identifier '_Unwind_Backtrace'
    _Unwind_Reason_Code t = _Unwind_Backtrace(unwind_callback, &info);
                            ^
1 error generated.



Expected results:

Build succesfully.
(Assignee)

Comment 1

5 years ago
Created attachment 650465 [details] [diff] [review]
define _GNU_SOURCE for _Unwind_Backtrace
(Assignee)

Comment 2

5 years ago
Comment on attachment 650465 [details] [diff] [review]
define _GNU_SOURCE for _Unwind_Backtrace

Unlike recent versions of GCC libunwind and libc++ put _Unwind_Backtrace under _GNU_SOURCE. However, configure script doesn't know this and just checks for the function in unwind.h irregardless of where it came from.

http://git.savannah.gnu.org/cgit/libunwind.git/tree/include/unwind.h
https://github.com/pathscale/libcxxrt/blob/master/src/unwind-itanium.h
Attachment #650465 - Flags: review?(dbaron)
(Assignee)

Updated

5 years ago
Component: General → XPCOM
Hardware: x86_64 → All
How did configure detect the function's presence if it's conditional on _GNU_SOURCE?

(You deleted config.cache and reran configure when changing compilers, right?)
(Assignee)

Comment 4

5 years ago
(In reply to David Baron [:dbaron] from comment #3)
> How did configure detect the function's presence if it's conditional on _GNU_SOURCE?

Configure script checks only header presence[1]. Then it goes to check libraries and finds that implicitly linked -lgcc_s provides _Unwind_Backtrace symbol.

$ env -i PATH=$PATH gmake conftest -f /dev/null
cc     conftest.c   -o conftest

$ cat conftest.c
#line 24094 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char _Unwind_Backtrace(); below.  */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char _Unwind_Backtrace();

int main() {

/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub__Unwind_Backtrace) || defined (__stub____Unwind_Backtrace)
choke me
#else
_Unwind_Backtrace();
#endif

; return 0; }


[1] more correct check would likely use AC_TRY_COMPILE, e.g.

dnl ========================================================
dnl = Support for gcc stack unwinding (from gcc 3.3)
dnl ========================================================
if test -z "$SKIP_LIBRARY_CHECKS"; then
    AC_LANG_CPLUSPLUS
    AC_MSG_CHECKING([for _Unwind_Backtrace in unwind.h])
    AC_TRY_COMPILE([#include <unwind.h>], [_Unwind_Backtrace(0,0)],
        AC_MSG_RESULT([found]),
        AC_TRY_COMPILE([#define _GNU_SOURCE
                #include <unwind.h>], [_Unwind_Backtrace(0,0)],
            AC_MSG_RESULT([needs -D_GNU_SOURCE]),
            AC_MSG_RESULT([not found])))
fi
(Assignee)

Updated

5 years ago
(Assignee)

Comment 5

5 years ago
On FreeBSD it usually is Blender port that pulls libunwind by default (CAMERATRACK option).
http://www.freshports.org/graphics/blender
(Assignee)

Comment 6

5 years ago
Note, clang has unwind.h since 3.1. The header is different from the one used by -stdlib=libc++, it doesn't need _GNU_SOURCE.

http://clang.llvm.org/doxygen/unwind_8h_source.html
Comment on attachment 650465 [details] [diff] [review]
define _GNU_SOURCE for _Unwind_Backtrace

r=dbaron
Attachment #650465 - Flags: review?(dbaron) → review+
(Assignee)

Comment 8

5 years ago
Created attachment 650792 [details] [diff] [review]
Bug 781457 - Define _GNU_SOURCE for _Unwind_Backtrace. r=dbaron
Attachment #650465 - Attachment is obsolete: true
(Assignee)

Updated

5 years ago
Keywords: checkin-needed
Green on Try:
https://tbpl.mozilla.org/?tree=Try&rev=1d57b70df30c

https://hg.mozilla.org/integration/mozilla-inbound/rev/115bed385a77
Assignee: nobody → jbeich
Flags: in-testsuite-
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/115bed385a77
Status: UNCONFIRMED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
(Assignee)

Updated

3 years ago
Blocks: 977457
You need to log in before you can comment on or make changes to this bug.