Page MenuHomeFreeBSD

Include <sys/cdefs.h> in execinfo.h
Needs RevisionPublic

Authored by arichardson on Mon, Dec 2, 9:39 AM.

Details

Reviewers
emaste
cem
Summary

Otherwise the LLVM CMake configure step does not detect that backtrace()
is available:

/local/scratch/alr48/cheri/output/sdk/sysroot128/usr/include/execinfo.h:37:1: error: unknown type name 'BEGIN_
DECLS'
BEGIN_DECLS
^
/local/scratch/alr48/cheri/output/sdk/sysroot128/usr/include/execinfo.h:38:7: error: expected ';' after top leve
l declarator
size_t backtrace(void **, size_t);

^

/local/scratch/alr48/cheri/output/sdk/sysroot128/usr/include/execinfo.h:43:1: error: unknown type name 'END_DECLS'
END_DECLS
^
CheckSymbolExists.c:8:19: error: use of undeclared identifier 'backtrace'

return ((int*)(&backtrace))[argc];
                ^

4 errors generated.
ninja: build stopped: subcommand failed.

File /local/scratch/alr48/cheri/build/llvm-project-mips-hybrid128-build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <execinfo.h>

int main(int argc, char** argv)
{

(void)argv;

#ifndef backtrace

return ((int*)(&backtrace))[argc];

#else

(void)argc;
return 0;

#endif
}

Diff Detail

Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 27883
Build 26054: arc lint + arc unit

Event Timeline

arichardson created this revision.Mon, Dec 2, 9:39 AM
emaste accepted this revision.Tue, Dec 10, 6:57 PM
emaste added a subscriber: cem.

Fine with me.

This revision is now accepted and ready to land.Tue, Dec 10, 6:57 PM
cem added a comment.EditedTue, Dec 10, 8:09 PM

This is for cross-building?

FreeBSD's stddef.h includes sys/cdefs.h. If you aren't finding FreeBSD's stddef.h in a cross build, why would you expect to find FreeBSD's sys/cdefs.h?

I guess glibc's sys/cdefs.h includes __BEGIN_DECLS, etc, but I don't know how portable that assumption is (no idea what MacOS has, and I don't know if windows environments like mingw64 have a sys/cdefs.h).

I'd prefer a more holistic approach — use the src tree FreeBSD's headers when we're cross-compiling, rather than the host's.

cem requested changes to this revision.Tue, Dec 10, 8:10 PM

Mark NACK for now. Maybe I misunderstand what is possible or something, help me understand :-).

This revision now requires changes to proceed.Tue, Dec 10, 8:10 PM
In D22630#497926, @cem wrote:

This is for cross-building?
FreeBSD's stddef.h includes sys/cdefs.h. If you aren't finding FreeBSD's stddef.h in a cross build, why would you expect to find FreeBSD's sys/cdefs.h?
I guess glibc's sys/cdefs.h includes __BEGIN_DECLS, etc, but I don't know how portable that assumption is (no idea what MacOS has, and I don't know if windows environments like mingw64 have a sys/cdefs.h).
I'd prefer a more holistic approach — use the src tree FreeBSD's headers when we're cross-compiling, rather than the host's.

Good catch, I didn't realize that stddef includes cdefs.h.

This happens when building llvm for cheribsd/MIPS on a x86 host. I have no idea why it's not pulling in cdefs.h. Possibly the build is using the compiler-provided stddef.h instead of the one from the sysroot. I'll investigate.