This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Fix search paths on x32
AbandonedPublic

Authored by jrtc27 on Feb 22 2018, 9:30 AM.

Details

Reviewers
rsmith
Summary

When targeting x32, the x32 libraries and headers should be used, not
the x86_64 ones (which may not even be available), so prioritise those
and use the right multiarch triple.

Diff Detail

Event Timeline

jrtc27 created this revision.Feb 22 2018, 9:30 AM

As a heads-up, powerpcspe needs a similar treatment as it suffers from the same problem:

cd build-llvm \
CFLAGS=`dpkg-buildflags --get CFLAGS`; \
CFLAGS="$CFLAGS `dpkg-buildflags --get CPPFLAGS`"; \
echo $CFLAGS; \
bin/clang++ -c $CFLAGS -std=c++11 ../lib/Fuzzer/*.cpp -IFuzzer; \
ar ruv libFuzzer.a Fuzzer*.o
-g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2
In file included from ../lib/Fuzzer/FuzzerCrossOver.cpp:12:
In file included from ../lib/Fuzzer/FuzzerDefs.h:15:
In file included from /usr/lib/gcc/powerpc-linux-gnuspe/7.3.0/../../../../include/c++/7.3.0/cassert:43:
In file included from /usr/lib/gcc/powerpc-linux-gnuspe/7.3.0/../../../../include/powerpc-linux-gnuspe/c++/7.3.0/bits/c++config.h:533:
In file included from /usr/lib/gcc/powerpc-linux-gnuspe/7.3.0/../../../../include/powerpc-linux-gnuspe/c++/7.3.0/bits/os_defines.h:39:
/usr/include/features.h:419:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^~~~~~~~~~~~~
1 error generated.
ar: `u' modifier ignored since `D' is the default (see `U')
ar: creating libFuzzer.a
ar: Fuzzer*.o: No such file or directory

Full build log in: https://people.debian.org/~glaubitz/llvm-toolchain-4.0_4.0.1-10.log.gz

Like x32, powerpcspe is just a variant on an existing architecture, namely powerpc but with a different ABI and hence a suffix in the GNU triplet name (full triplet name is "powerpc-linux-gnuspe").

rnk removed a reviewer: rnk.Aug 22 2018, 6:57 AM

This should probably have some tests. It looks like there are some existing x32 tests in test/Driver/linux-header-search.cpp and test/Driver/cross-linux.c that might be relevant for updating.

@jrtc27 are you going to take care of the tests? Thanks

I have just rebased the patch and I am looking at the tests now.

I don't think that "test/Driver/linux-header-search.cpp" needs to be updated. x32 is actually supported in both an x86_64-linux-gnu environment and x86_64-linux-gnux32 environment. In order to update test/Driver/linux-header-search.cpp, we would have to add a debian-10-x32 chroot to the LLVM test environment. However, the patch by @jrtc27 actually doesn't break the previous tests as his patch just allows the native header and library paths as altnernative search paths.

The same applies to test/Driver/cross-linux.c. The x32 test there will still remain valid, even with the changes.

I have pushed a rebase revision here: https://reviews.llvm.org/D52050

I have no idea how to edit the author though.

jrtc27 abandoned this revision.Aug 9 2022, 11:47 AM

Superseded by D52050

Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2022, 11:47 AM
Herald added a subscriber: pengfei. · View Herald Transcript