* Add aarch64-* symlinks for arm64-*. Automake doesn't recognize arm64.

* Some cleanup
This commit is contained in:
Thomas Pöchtrager 2020-08-20 18:41:43 +02:00
parent 749cf4acad
commit 956a2ea676
4 changed files with 97 additions and 84 deletions

View File

@ -132,37 +132,35 @@ if [ $f_res -eq 1 ]; then
$MAKE -j$JOBS
$MAKE install -j$JOBS
popd &>/dev/null
pushd $TARGET_DIR/bin &>/dev/null
CCTOOLS=$(find . -name "x86_64-apple-darwin*")
CCTOOLS=($CCTOOLS)
if [ $X86_64H_SUPPORTED -eq 1 ]; then
for CCTOOL in ${CCTOOLS[@]}; do
CCTOOL_X86_64H=$(echo "$CCTOOL" | $SED 's/x86_64/x86_64h/g')
create_symlink $CCTOOL $CCTOOL_X86_64H
done
fi
if [ $I386_SUPPORTED -eq 1 ]; then
for CCTOOL in ${CCTOOLS[@]}; do
CCTOOL_I386=$(echo "$CCTOOL" | $SED 's/x86_64/i386/g')
create_symlink $CCTOOL $CCTOOL_I386
done
fi
if [ $ARM_SUPPORTED -eq 1 ]; then
for CCTOOL in ${CCTOOLS[@]}; do
CCTOOL_ARM64=$(echo "$CCTOOL" | $SED 's/x86_64/arm64/g')
create_symlink $CCTOOL $CCTOOL_ARM64
done
for CCTOOL in ${CCTOOLS[@]}; do
CCTOOL_ARM64E=$(echo "$CCTOOL" | $SED 's/x86_64/arm64e/g')
create_symlink $CCTOOL $CCTOOL_ARM64E
done
fi
# For unpatched dsymutil. There is currently no way around it.
create_symlink x86_64-apple-$TARGET-lipo lipo
popd &>/dev/null
fi
## Create Arch Symlinks ##
pushd $TARGET_DIR/bin &>/dev/null
CCTOOLS=($(find . -name "x86_64-apple-${TARGET}*"))
function create_arch_symlinks()
{
local arch=$1
for CCTOOL in ${CCTOOLS[@]}; do
verbose_cmd create_symlink $CCTOOL $(echo "$CCTOOL" | $SED "s/x86_64/$arch/g")
done
}
if [ $X86_64H_SUPPORTED -eq 1 ]; then
create_arch_symlinks "x86_64h"
fi
if [ $I386_SUPPORTED -eq 1 ]; then
create_arch_symlinks "i386"
fi
if [ $ARM_SUPPORTED -eq 1 ]; then
create_arch_symlinks "aarch64"
create_arch_symlinks "arm64"
create_arch_symlinks "arm64e"
fi
# For unpatched dsymutil. There is currently no way around it.
create_symlink x86_64-apple-$TARGET-lipo lipo
popd &>/dev/null
## MacPorts ##
@ -271,6 +269,7 @@ if [ $X86_64H_SUPPORTED -eq 1 ]; then
fi
if [ $ARM_SUPPORTED -eq 1 ]; then
create_symlink osxcross-cmake "$TARGET_DIR/bin/aarch64-apple-$TARGET-cmake"
create_symlink osxcross-cmake "$TARGET_DIR/bin/arm64-apple-$TARGET-cmake"
create_symlink osxcross-cmake "$TARGET_DIR/bin/arm64e-apple-$TARGET-cmake"
fi
@ -360,6 +359,14 @@ echo "Example 3: o64-clang -Wall test.c -o test"
echo "Example 4: x86_64-apple-$TARGET-strip -x test"
echo ""
if [ $ARM_SUPPORTED -eq 1 ]; then
echo "!!! Use aarch64-apple-$TARGET-* instead of arm64-* when dealing with Automake !!!"
echo "!!! CC=aarch64-apple-$TARGET-clang ./configure --host=aarch64-apple-$TARGET !!!"
echo "!!! CC=\"aarch64-apple-$TARGET-clang -arch arm64e\" ./configure --host=aarch64-apple-$TARGET !!!"
echo ""
fi
if [ $I386_SUPPORTED -eq 0 ]; then
echo "Your SDK does not support i386 anymore."
echo "Use <= 10.13 SDK if you rely on i386 support."

View File

@ -82,6 +82,8 @@ function create_wrapper_link
fi
if [ $ARM_SUPPORTED -eq 1 ]; then
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
"aarch64-apple-${TARGET}-${1}"
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \
"arm64-apple-${TARGET}-${1}"
verbose_cmd create_symlink "${TARGETTRIPLE}-wrapper" \

View File

@ -373,8 +373,8 @@ void detectCXXLib(Target &target) {
bool detectTarget(int argc, char **argv, Target &target) {
const char *cmd = argv[0];
const char *p = strrchr(cmd, '/');
char archName[16];
size_t len;
size_t i = 0;
if (p)
cmd = &p[1];
@ -386,51 +386,54 @@ bool detectTarget(int argc, char **argv, Target &target) {
p = strchr(cmd, '-');
len = (p ? p : cmd) - cmd;
for (auto arch : ArchNames) {
++i;
if (len >= sizeof(archName))
return false;
if (!strncmp(cmd, arch, len)) {
target.arch = static_cast<Arch>(i - 1);
cmd += len;
memcpy(archName, cmd, len);
archName[len] = '\0';
if (*cmd++ != '-')
return false;
target.arch = parseArch(archName);
if (strncmp(cmd, "apple-", 6))
return false;
if (target.arch != Arch::unknown) {
cmd += len;
cmd += 6;
if (*cmd++ != '-')
return false;
if (strncmp(cmd, "darwin", 6))
return false;
if (strncmp(cmd, "apple-", 6))
return false;
if (!(p = strchr(cmd, '-')))
return false;
cmd += 6;
target.target = std::string(cmd, p - cmd);
target.compiler = getCompilerIdentifier(&p[1]);
target.compilername = &p[1];
if (strncmp(cmd, "darwin", 6))
return false;
if (target.compilername == "cc") {
target.compiler = getDefaultCompilerIdentifier();
target.compilername = getDefaultCompilerName();
} else if (target.compilername == "c++") {
target.compiler = getDefaultCXXCompilerIdentifier();
target.compilername = getDefaultCXXCompilerName();
} else if (auto *prog = program::getprog(target.compilername)) {
(*prog)(argc, argv, target);
}
if (!(p = strchr(cmd, '-')))
return false;
if (target.target != getDefaultTarget())
warn << "this wrapper was built for target "
<< "'" << getDefaultTarget() << "'" << warn.endl();
target.target = std::string(cmd, p - cmd);
target.compiler = getCompilerIdentifier(&p[1]);
target.compilername = &p[1];
if (!commandopts::parse(argc, argv, target))
return false;
detectCXXLib(target);
return target.setup();
if (target.compilername == "cc") {
target.compiler = getDefaultCompilerIdentifier();
target.compilername = getDefaultCompilerName();
} else if (target.compilername == "c++") {
target.compiler = getDefaultCXXCompilerIdentifier();
target.compilername = getDefaultCXXCompilerName();
} else if (auto *prog = program::getprog(target.compilername)) {
(*prog)(argc, argv, target);
}
if (target.target != getDefaultTarget())
warn << "this wrapper was built for target "
<< "'" << getDefaultTarget() << "'" << warn.endl();
if (!commandopts::parse(argc, argv, target))
return false;
detectCXXLib(target);
return target.setup();
}
if (!strncmp(cmd, "o32", 3))

View File

@ -379,19 +379,7 @@ inline Compiler getCompilerIdentifier(const char *compilername) {
//
enum Arch {
armv4t,
armv5,
armv6,
armv7,
armv7f,
armv7k,
armv7s,
armv6m,
armv7m,
armv7em,
armv8,
arm64,
arm64v8,
arm64e,
i386,
i486,
@ -399,21 +387,29 @@ enum Arch {
i686,
x86_64,
x86_64h, // Haswell
ppc,
ppc64,
unknown
};
constexpr const char *ArchNames[] = {
"armv4t", "armv5", "armv6", "armv7", "armv7f", "armv7k", "armv7s",
"amrv6m", "armv7m", "armv7em", "armv8", "arm64", "arm64v8", "arm64e",
"i386", "i486", "i586", "i686", "x86_64", "x86_64h", "ppc",
"ppc64", "unknown"
"arm64",
"arm64e",
"i386",
"i486",
"i586",
"i686",
"x86_64",
"x86_64h",
"unknown"
};
constexpr const char *getArchName(Arch arch) { return ArchNames[arch]; }
constexpr const char *getArchName(Arch arch) {
return ArchNames[arch];
}
inline Arch parseArch(const char *arch) {
if (!strcmp(arch, "aarch64")) // treat aarch64 as arm64
return Arch::arm64;
size_t i = 0;
for (auto archname : ArchNames) {
if (!strcmp(arch, archname)) {
@ -421,6 +417,7 @@ inline Arch parseArch(const char *arch) {
}
++i;
}
return Arch::unknown;
}
@ -434,7 +431,11 @@ enum StdLib {
libstdcxx
};
constexpr const char *StdLibNames[] = { "default", "libc++", "libstdc++" };
constexpr const char *StdLibNames[] = {
"default",
"libc++",
"libstdc++"
};
constexpr const char *getStdLibString(StdLib stdlib) {
return StdLibNames[stdlib];