Android build broken with clang 8
Categories
(Firefox Build System :: General, defect)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: glandium, Assigned: glandium)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
Comment 1•6 years ago
|
||
Updated•6 years ago
|
Assignee | ||
Comment 2•6 years ago
|
||
(In reply to Nathan Froyd [:froydnj] from comment #1)
That seems weird that the switch of standard libraries would cause problems
in a C header.
Here's what happens:
including stddef.h includes /builds/worker/workspace/build/src/android-ndk/sources/cxx-stl/llvm-libc++/include/stddef.h, which does this:
#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \
defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t)
// (...)
#include_next <stddef.h>
#elif !defined(_LIBCPP_STDDEF_H)
#define _LIBCPP_STDDEF_H
// (...)
#include_next <stddef.h>
#endif
And with -stdlib=libstdc++, the #include_next
gets /builds/worker/workspace/build/src/clang/lib/clang/8.0.0/include/stddef.h, which defines size_t and others.
With -stdlib=libc++, the #include_next
gets /builds/worker/workspace/build/src/clang/bin/../include/c++/v1/stddef.h, which... does the same thing as /builds/worker/workspace/build/src/android-ndk/sources/cxx-stl/llvm-libc++/include/stddef.h, but we got here from the second branch there, so _LIBCPP_STDDEF_H is defined, and the next stddef.h is not included.
So the problem we have is that we use different libc++ headers manually, while clang wants to use its own too.
It seems the solution here could be to replace the -I$NDK/sources/cxx-stl/llvm-libc++ with -stdlib=libc++, but I'm not sure how it would work out with older versions of clang.
Nathan, do you remember why you went with -I in bug 1164921?
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 3•6 years ago
|
||
but I'm not sure how it would work out with older versions of clang.
In fact, I'm not even sure it would work out fine with this version of clang...
Assignee | ||
Comment 4•6 years ago
|
||
Nathan, do you remember why you went with -I in bug 1164921?
Was it maybe because we were using clang from the NDK back then? I guess -stdlib=libc++ wouldn't work with that...
Comment 5•6 years ago
|
||
(In reply to Mike Hommey [:glandium] from comment #4)
Nathan, do you remember why you went with -I in bug 1164921?
Was it maybe because we were using clang from the NDK back then? I guess -stdlib=libc++ wouldn't work with that...
That seems like a much nicer explanation than the one I was going to give about me doing the expedient thing rather than the correct thing. -stdlib might not have been supported at that point, too.
Assignee | ||
Comment 6•6 years ago
|
||
We shouldn't pass those flags when building C. It doesn't matter /too/
much currently, but will in a subsequent change, which will introduce
a C++-only flag in stlport_cppflags.
Assignee | ||
Comment 7•6 years ago
|
||
There is no concern that the Android NDK clang may not support it, as
the flag was added in clang 2.9. The flag is also not supported with
GCC, which is not ideal, but we already crossed that bridge at least
with -gcc-toolchain added in extra_toolchain_flags, which is not
supported by GCC either.
Assignee | ||
Comment 8•6 years ago
|
||
Somehow this was left alone in bug 1509926, although the file was
mentioned there.
Assignee | ||
Comment 9•6 years ago
|
||
As of clang 8, llvm-config doesn't return all flags clang was built
with, and omits some flags that do impact the libclang ABI,
-stdlib=libc++ being one of them (it might well be the only one).
Building clang with LLVM_ENABLE_LIBCXX=ON does build it with
-stdlib=libc++, but is unrelated to whether or not libc++ is built and
shipped with clang, which still happens without it.
So while versions older than clang 8 are not really affected, it doesn't
hurt to build clang without -stdlib=libc++ (especially when it
currently only applies to the clang used to cross build android with
PGO, not even the other android cross builds), in preparation for
switching to clang 8.
Assignee | ||
Updated•6 years ago
|
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a5b86fb8a24a
https://hg.mozilla.org/mozilla-central/rev/550fed2c6b07
https://hg.mozilla.org/mozilla-central/rev/a508fc434362
https://hg.mozilla.org/mozilla-central/rev/656e3d5c59be
Updated•6 years ago
|
Description
•