Open Bug 1747150 Opened 3 years ago Updated 1 year ago

Configure should check that including C++ headers takes them from the sysroot

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: Sylvestre, Unassigned)

Details

+++ This bug was initially created as a clone of Bug #1747145 +++

using apt.llvm.org packages:

sudo debootstrap bullseye bullseye.dir
sudo mount -t proc /proc bullseye.dir/proc
sudo mount -t proc /dev/pts bullseye.dir/dev/pts
sudo mount -t tmpfs tmpfs  bullseye.dir/dev/shm
sudo chroot bullseye.dir
apt install mercurial wget lsb-release wget software-properties-common gnupg2 python3-distutils python3-pip
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh 11
hg clone https://hg.mozilla.org/mozilla-central/
cd mozilla-central
echo "
ac_add_options --disable-av1
export CC=clang-11
export CXX=clang++-11

mk_add_options MOZ_MAKE_FLAGS="-j14"
ac_add_options --enable-debug
ac_add_options --disable-gtest-in-build
ac_add_options --enable-bootstrap

" > .mozconfig

./mach bootstrap
./mach build
 0:04.67 /usr/bin/clang++-11 --sysroot /root/.mozbuild/sysroot-x86_64-linux-gnu -std=gnu++17 -o AtkSocketAccessible.o -c  -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/system_wrappers -include /root/mozilla-central/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -ftrivial-auto-var-init=pattern -DDEBUG=1 -DOS_POSIX=1 -DOS_LINUX=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/root/mozilla-central/accessible/atk -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/accessible/atk -I/root/mozilla-central/accessible/base -I/root/mozilla-central/accessible/generic -I/root/mozilla-central/accessible/html -I/root/mozilla-central/accessible/ipc -I/root/mozilla-central/accessible/ipc/other -I/root/mozilla-central/accessible/xpcom -I/root/mozilla-central/accessible/xul -I/root/mozilla-central/layout/generic -I/root/mozilla-central/other-licenses/atk-1.0 -I/root/mozilla-central/widget -I/root/mozilla-central/widget/gtk -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I/root/mozilla-central/ipc/chromium/src -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include/nspr -I/root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include/nss -DMOZILLA_CLIENT -include /root/mozilla-central/obj-x86_64-pc-linux-gnu/mozilla-config.h -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wdeprecated-this-capture -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wenum-compare-conditional -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-psabi -Wno-unknown-warning-option -fno-sized-deallocation -fno-aligned-new -fno-exceptions -fno-strict-aliasing -fPIC -fno-rtti -fno-exceptions -fno-math-errno -pthread -pipe -g -Os -fno-omit-frame-pointer -funwind-tables -I/root/mozilla-central/widget/gtk/compat-gtk3 -pthread -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/gtk-3.0/unix-print -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/gtk-3.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/at-spi2-atk/2.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/at-spi-2.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/dbus-1.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/gtk-3.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/cairo -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/pango-1.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/harfbuzz -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/pango-1.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/atk-1.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/cairo -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/pixman-1 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/freetype2 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/libpng12 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/gdk-pixbuf-2.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/libpng12 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/gio-unix-2.0/ -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/glib-2.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/dbus-1.0 -I/root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/dbus-1.0/include -Wno-error=unused-function -Wno-unused-local-typedefs -fexperimental-new-pass-manager  -MD -MP -MF .deps/AtkSocketAccessible.o.pp  -fcolor-diagnostics  /root/mozilla-central/accessible/atk/AtkSocketAccessible.cpp

 0:05.69 In file included from /root/mozilla-central/accessible/atk/AtkSocketAccessible.cpp:8:
 0:05.69 In file included from /root/mozilla-central/accessible/atk/AtkSocketAccessible.h:10:
 0:05.69 In file included from /root/mozilla-central/accessible/atk/AccessibleWrap.h:11:
 0:05.69 In file included from /root/mozilla-central/accessible/generic/LocalAccessible.h:9:
 0:05.69 In file included from /root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include/mozilla/a11y/Accessible.h:12:
 0:05.69 In file included from /root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include/nsRect.h:14:
 0:05.69 In file included from /root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include/mozilla/gfx/Rect.h:14:
 0:05.69 In file included from /root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/include/mozilla/gfx/Tools.h:10:
 0:05.69 In file included from /root/mozilla-central/obj-x86_64-pc-linux-gnu/dist/system_wrappers/math.h:3:
 0:05.69 /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/math.h:66:12: error: target of using declaration conflicts with declaration already in scope
 0:05.69 using std::isnan;
 0:05.69            ^
 0:05.69 /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cmath:619:3: note: target of using declaration
 0:05.69   isnan(double __x)
 0:05.69   ^
 0:05.69 /root/.mozbuild/sysroot-x86_64-linux-gnu/usr/include/x86_64-linux-gnu/bits/mathcalls.h:234:19: note: conflicting declaration
 0:05.69 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
 0:05.69                   ^

So it looks like clang has a different behavior depending on whether it's /usr/bin/clang* or something else:

 /usr/bin/clang++-11 -v --sysroot /root/.mozbuild/sysroot-x86_64-linux-gnu
Debian clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214627.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

# /usr/lib/llvm-11/bin/clang++ -v --sysroot /root/.mozbuild/sysroot-x86_64-linux-gnu
Debian clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214627.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-11/bin
Found candidate GCC installation: /root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7.5.0
Selected GCC installation: /root/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64

If I change /usr/bin/clang++-13 from being a symlink to being a script that does exec /usr/lib/llvm-11/bin/clang++ "$@", then it works.

I'm not convinced this behavior of clang is wanted (especially when using a sysroot). It seems to me clang should canonicalize argv[0] before doing these lookups (that one is explicitly relative to the clang directory, it separately looks for /usr/lib/gcc).

clang++-11 -v
Debian clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214627.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

We could add the include paths in the build system, but I'm not sure we should. We could also canonicalize the clang path in configure, but I suspect that would have other adverse effects (like when /usr/lib/ccache is in the PATH).

In any case, we should probably add a configure check for this.

I'm not convinced this behavior of clang is wanted (especially when using a sysroot).

Well, it doesn't happen since llvm 13...

Summary: Debian bullseye with clang-11: error: target of using declaration conflicts with declaration already in scope → Configure should check that including C++ headers takes them from the sysroot
Priority: -- → P3

Workaround if others have the same issue:

ac_add_options --without-sysroot
You need to log in before you can comment on or make changes to this bug.