2
0
Fork 0

Move Nixpkgs patching to overlay

This commit is contained in:
Emery Hemingway 2020-03-24 18:17:30 +05:30
parent a0a31fa548
commit 14fc773ac9
65 changed files with 6917 additions and 46 deletions

19
LICENSES/MIT.txt Normal file
View File

@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -36,36 +36,20 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgsUpstream": {
"info": {
"lastModified": 1584695415,
"narHash": "sha256-qIofBjFM7MZLyKrUq3rCauF8GpAsqKfIzzVX2hDA0a4="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a08d4f605bca62c282ce9955d5ddf7d824e89809",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"info": { "info": {
"lastModified": 1583160598, "lastModified": 1585044620,
"narHash": "sha256-jiBSr7JK/xy7pIXFVhjdxpWy0pudDDRDW5XjzmDXPjA=" "narHash": "sha256-719eq/d2G5RM5sKJjbQw2MHHCw0E9EOwQturM3jeXqA="
}, },
"locked": { "locked": {
"owner": "ehmry", "owner": "ehmry",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "37cf068dcf79503fa6f399dcb44bc15c5d2f33f0", "rev": "563dcf1c8b3a034edc948eed03a4a176647f8ae2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "ehmry", "owner": "ehmry",
"ref": "tier7",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -73,8 +57,7 @@
"root": { "root": {
"inputs": { "inputs": {
"genode-depot": "genode-depot", "genode-depot": "genode-depot",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2"
"nixpkgsUpstream": "nixpkgsUpstream"
} }
} }
}, },

View File

@ -7,11 +7,15 @@
inputs = { inputs = {
genode-depot.uri = "git+https://git.sr.ht/~ehmry/genode-depot"; genode-depot.uri = "git+https://git.sr.ht/~ehmry/genode-depot";
nixpkgs.uri = "github:ehmry/nixpkgs"; nixpkgs = {
nixpkgsUpstream.uri = "github:NixOS/nixpkgs"; type = "github";
owner = "ehmry";
repo = "nixpkgs";
ref = "tier7";
};
}; };
outputs = { self, genode-depot, nixpkgs, nixpkgsUpstream }: outputs = { self, genode-depot, nixpkgs }:
let let
localSystems = [ "x86_64-linux" ]; localSystems = [ "x86_64-linux" ];
crossSystems = [ "x86_64-genode" ]; crossSystems = [ "x86_64-genode" ];
@ -42,13 +46,17 @@
nixpkgsFor = forAllSystems ({ system, localSystem, crossSystem }: nixpkgsFor = forAllSystems ({ system, localSystem, crossSystem }:
if localSystem == crossSystem then if localSystem == crossSystem then
import nixpkgsUpstream { import nixpkgs {
inherit system; inherit system;
overlays = [ self.overlay ]; overlays = [ self.overlay ];
} }
else else
import nixpkgs { import nixpkgs {
inherit localSystem crossSystem; inherit localSystem;
crossSystem = {
system = crossSystem;
useLLVM = true;
};
config.allowUnsupportedSystem = true; config.allowUnsupportedSystem = true;
overlays = [ self.overlay ]; overlays = [ self.overlay ];
}); });
@ -75,7 +83,7 @@
inherit system; inherit system;
legacyPackages = self.legacyPackages.${system}; legacyPackages = self.legacyPackages.${system};
apps = self.apps.${system}; apps = self.apps.${system};
localPackages = nixpkgsUpstream.legacyPackages.${localSystem}; localPackages = nixpkgs.legacyPackages.${localSystem};
depot = genode-depot.packages.${system}; depot = genode-depot.packages.${system};
}); });
@ -102,7 +110,8 @@
runScript = "bash"; runScript = "bash";
extraBuildCommands = let extraBuildCommands = let
toolchain = pkgs.fetchzip { toolchain = pkgs.fetchzip {
url = "file://${packages.x86_64-linux-x86_64-genode.genodeSources.toolchain.src}"; url =
"file://${packages.x86_64-linux-x86_64-genode.genodeSources.toolchain.src}";
hash = "sha256-26rPvLUPEJm40zLSqTquwuFTJ1idTB0T4VXgaHRN+4o="; hash = "sha256-26rPvLUPEJm40zLSqTquwuFTJ1idTB0T4VXgaHRN+4o=";
}; };
in "ln -s ${toolchain}/local usr/local"; in "ln -s ${toolchain}/local usr/local";
@ -113,21 +122,25 @@
shellHook = "exec genode-env"; shellHook = "exec genode-env";
}); });
apps = forAllCrossSystems ({ system, localSystem, crossSystem }: apps = let
import ./apps { apps' = forAllCrossSystems ({ system, localSystem, crossSystem }:
self = self.apps.${system}; import ./apps {
nixpkgs = self.legacyPackages.${system}; self = self.apps.${system};
nixpkgsLocal = nixpkgsFor.${localSystem}; nixpkgs = self.legacyPackages.${system};
packages = self.packages.${system}; nixpkgsLocal = nixpkgsFor.${localSystem};
}); packages = self.packages.${system};
});
in apps' // { x86_64-linux = apps'.x86_64-linux-x86_64-genode; };
checks = forAllCrossSystems ({ system, localSystem, crossSystem }: checks = let
import ./tests { checks' = forAllCrossSystems ({ system, localSystem, crossSystem }:
inherit system localSystem crossSystem; import ./tests {
inherit self nixpkgs genode-depot; inherit system localSystem crossSystem;
apps = self.apps.${system}; inherit self nixpkgs genode-depot;
lib = self.lib.${system}; apps = self.apps.${system};
genodepkgs = self.packages.${system}; lib = self.lib.${system};
}); genodepkgs = self.packages.${system};
});
in checks' // { x86_64-linux = checks'.x86_64-linux-x86_64-genode; };
}; };
} }

View File

@ -0,0 +1,83 @@
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 6391f35684..f2ab802fb5 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -554,7 +554,7 @@ case "${targ}" in
targ_selvecs=hppa_elf32_vec
;;
- i[3-7]86-*-elf* | i[3-7]86-*-rtems*)
+ i[3-7]86-*-elf* | i[3-7]86-*-rtems* | i[3-7]86-*-genode*)
targ_defvec=i386_elf32_vec
targ_selvecs="iamcu_elf32_vec i386_coff_vec"
;;
@@ -662,7 +662,7 @@ case "${targ}" in
targ_selvecs="i386_elf32_vec iamcu_elf32_vec l1om_elf64_vec k1om_elf64_vec"
want64=true
;;
- x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia)
+ x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia | x86_64-*-genode*)
targ_defvec=x86_64_elf64_vec
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec l1om_elf64_vec k1om_elf64_vec"
case "${targ}" in
diff --git a/config.sub b/config.sub
index c95acc681d..388c305636 100755
--- a/config.sub
+++ b/config.sub
@@ -1376,7 +1376,7 @@ case $os in
| powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
- | midnightbsd*)
+ | midnightbsd* | genode*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
qnx*)
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 3d0415c1aa..7cd96b6be4 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -139,7 +139,8 @@ case ${generic_target} in
arm-*-phoenix*) fmt=elf ;;
arm-*-elf) fmt=elf ;;
- arm-*-eabi* | arm-*-rtems*) fmt=elf em=armeabi ;;
+ arm-*-eabi* | arm-*-rtems* | arm-*-genode*)
+ fmt=elf em=armeabi ;;
arm-*-symbianelf*) fmt=elf em=symbian ;;
arm-*-kaos*) fmt=elf ;;
arm-*-conix*) fmt=elf ;;
@@ -213,6 +214,7 @@ case ${generic_target} in
i386-*-elfiamcu) fmt=elf arch=iamcu ;;
i386-*-elf*) fmt=elf ;;
i386-*-fuchsia*) fmt=elf ;;
+ i386-*-genode*) fmt=elf ;;
i386-*-kaos*) fmt=elf ;;
i386-*-bsd*) fmt=aout em=386bsd ;;
i386-*-nacl*) fmt=elf em=nacl
diff --git a/ld/configure.tgt b/ld/configure.tgt
index fad8b2e5c8..04f7fa0e70 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -115,7 +115,7 @@ arm-*-nto*) targ_emul=armnto ;;
arm-*-phoenix*) targ_emul=armelf ;;
armeb-*-elf | armeb-*-eabi*)
targ_emul=armelfb ;;
-arm-*-elf | arm*-*-eabi* | arm-*-rtems*)
+arm-*-elf | arm*-*-eabi* | arm-*-rtems* | arm-*-genode*)
targ_emul=armelf ;;
arm*-*-symbianelf*) targ_emul=armsymbian;;
arm-*-kaos*) targ_emul=armelf ;;
@@ -302,10 +302,10 @@ x86_64-*-netbsd*) targ_emul=elf_x86_64
esac ;;
i[3-7]86-*-elfiamcu) targ_emul=elf_iamcu
targ_extra_emuls=elf_i386 ;;
-i[3-7]86-*-elf* | i[3-7]86-*-rtems*)
+i[3-7]86-*-elf* | i[3-7]86-*-rtems* | i[3-7]86-*-genode*)
targ_emul=elf_i386
targ_extra_emuls=elf_iamcu ;;
-x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia*)
+x86_64-*-elf* | x86_64-*-rtems* | x86_64-*-fuchsia* | x86_64-*-genode*)
targ_emul=elf_x86_64
targ_extra_emuls="elf_i386 elf_iamcu elf32_x86_64 elf_l1om elf_k1om"
targ_extra_libpath="elf_i386 elf_iamcu elf32_x86_64 elf_l1om elf_k1om"

View File

@ -0,0 +1,32 @@
set(GENODE 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} "-pie")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "-no-pie")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
# Disable the stack protector until a later stage of LLVM migration
set(CMAKE_C_FLAGS "-fno-stack-protector")
set(CMAKE_CXX_FLAGS "-fno-stack-protector")
# Shared libraries with no builtin soname may not be linked safely by
# specifying the file path.
set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1)
# Initialize C link type selection flags. These flags are used when
# building a shared library, shared module, or executable that links
# to other libraries to select whether to use the static or shared
# versions of the libraries.
foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic")
set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
endforeach()

View File

@ -1,3 +1,40 @@
final: prev: { final: prev:
with prev; {
binutils-unwrapped = prev.binutils-unwrapped.overrideAttrs (attrs: {
patches = attrs.patches ++ lib.optional targetPlatform.isGenode
[ ./binutils/support-genode.patch ];
});
cmake = prev.cmake.overrideAttrs (attrs: {
postInstall = with stdenv;
if targetPlatform.isGenode then ''
local MODULE="$out/share/cmake-${
lib.versions.majorMinor attrs.version
}/Modules/Platform/Genode.cmake"
if [ -e "$MODULE" ]; then
echo "Upstream provides $MODULE!"
exit 1
fi
cp ${./cmake/Genode.cmake} $MODULE
'' else
null;
});
genodeHeaders = callPackage ./headers { };
genodeLibcCross = callPackage ./libc { stdenv = crossLibcStdenv; };
libcCrossChooser = name:
if stdenv.targetPlatform.isGenode then
targetPackages.genodeLibcCross or genodeLibcCross
else
prev.libcCrossChooser name;
llvmPackages_8 = callPackage ./llvm-8 ({
inherit (stdenvAdapters) overrideCC;
buildLlvmTools = buildPackages.llvmPackages_8.tools;
targetLlvmLibraries = targetPackages.llvmPackages_8.libraries;
});
} }

View File

@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: Emery Hemingway
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
{ stdenvNoCC, lib, fetchurl }:
let
stdenv = stdenvNoCC;
version = "20.02";
platform = stdenv.targetPlatform;
in stdenv.mkDerivation {
pname = platform.system + "-headers";
inherit version;
src = fetchurl {
url = "https://github.com/genodelabs/genode/archive/${version}.tar.gz";
hash = "sha256-ZY9ND6vDA9u127TAv87uOjPuLzRzBPyp5PzD6iM7uNI=";
};
specs = with platform; []
++ lib.optional is32bit "32bit"
++ lib.optional is64bit "64bit"
++ lib.optional isAarch32 "arm"
++ lib.optional isAarch64 "arm_64"
++ lib.optional isRiscV "riscv"
++ lib.optional isx86 "x86"
++ lib.optional isx86_32 "x86_32"
++ lib.optional isx86_64 "x86_64";
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
tar fx $src \
--strip-components=2 \
genode-$version/repos/base \
genode-$version/repos/demo/include \
genode-$version/repos/gems/include \
genode-$version/repos/libports/include \
genode-$version/repos/os/include \
genode-$version/repos/ports/include \
includeDir=$out/include
mkdir -p $includeDir
for DIR in */include; do
for SPEC in $specs; do
if [ -d $DIR/spec/$SPEC ]; then
cp -r $DIR/spec/$SPEC/* $includeDir/
rm -r $DIR/spec/$SPEC
fi
done
rm -rf $DIR/spec
cp -r $DIR/* $includeDir
done
mkdir $out/ld
cp \
base/src/ld/genode_dyn.dl \
base/src/ld/genode_dyn.ld \
base/src/ld/genode_rel.ld \
$out/ld
'';
}

View File

@ -0,0 +1,24 @@
--- src/lib/libc/include/stdlib.h.orig 2019-04-18 13:26:58.781188866 +0200
+++ src/lib/libc/include/stdlib.h 2019-04-18 13:27:46.100594001 +0200
@@ -81,7 +81,8 @@
#endif
extern int __mb_cur_max;
extern int ___mb_cur_max(void);
-#define MB_CUR_MAX ((size_t)___mb_cur_max())
+/* ASCII only */
+#define MB_CUR_MAX 1
_Noreturn void abort(void);
int abs(int) __pure2;
--- src/lib/libc/include/xlocale/_stdlib.h.orig 2019-04-18 13:28:52.691756865 +0200
+++ src/lib/libc/include/xlocale/_stdlib.h 2019-04-18 13:29:13.079500565 +0200
@@ -57,5 +57,6 @@
int wctomb_l(char *, wchar_t, locale_t);
int ___mb_cur_max_l(locale_t);
-#define MB_CUR_MAX_L(x) ((size_t)___mb_cur_max_l(x))
+/* ASCII only */
+#define MB_CUR_MAX_L(x) 1

View File

@ -0,0 +1,23 @@
--- src/lib/libc/include/runetype.h.orig 2019-04-16 11:51:27.954530199 +0200
+++ src/lib/libc/include/runetype.h 2019-04-16 11:51:53.346901123 +0200
@@ -88,19 +88,7 @@
__BEGIN_DECLS
extern const _RuneLocale _DefaultRuneLocale;
extern const _RuneLocale *_CurrentRuneLocale;
-#if defined(__NO_TLS) || defined(__RUNETYPE_INTERNAL)
-extern const _RuneLocale *__getCurrentRuneLocale(void);
-#else
-extern _Thread_local const _RuneLocale *_ThreadRuneLocale;
-static __inline const _RuneLocale *__getCurrentRuneLocale(void)
-{
-
- if (_ThreadRuneLocale)
- return _ThreadRuneLocale;
- return _CurrentRuneLocale;
-}
-#endif /* __NO_TLS || __RUNETYPE_INTERNAL */
-#define _CurrentRuneLocale (__getCurrentRuneLocale())
+#define _CurrentRuneLocale (&_DefaultRuneLocale)
__END_DECLS
#endif /* !_RUNETYPE_H_ */

View File

@ -0,0 +1,63 @@
Prevent the use of the hidden attribute for symbols. In particular,
the attribute must not be applied to '__libc'-prefixed symbols to allow
overwriting the dummies defined in dummies.cc by other non-weak
implementations such as those in 'libc_noux.lib.so'.
This attribute is applied inconsistently in
libc/lib/libc/include/libc_private.h anyway.
Also, force i386 to call __libc_sigprocmask via PLT to prevent
R_386_PC32 relocations, which had to change the text segment. Other
architectures do this automatically.
--- src/lib/libc/sys/sys/cdefs.h
+++ src/lib/libc/sys/sys/cdefs.h
@@ -447,7 +447,7 @@
#if __GNUC_PREREQ__(4, 0)
#define __null_sentinel __attribute__((__sentinel__))
#define __exported __attribute__((__visibility__("default")))
-#define __hidden __attribute__((__visibility__("hidden")))
+#define __hidden
#else
#define __null_sentinel
#define __exported
--- src/lib/libc/lib/libc/i386/gen/setjmp.S
+++ src/lib/libc/lib/libc/i386/gen/setjmp.S
@@ -54,7 +54,7 @@
pushl %eax /* (sigset_t*)oset */
pushl $0 /* (sigset_t*)set */
pushl $1 /* SIG_BLOCK */
- call __libc_sigprocmask
+ call __i386_libc_sigprocmask
addl $12,%esp
movl 4(%esp),%ecx
movl 0(%esp),%edx
@@ -76,7 +76,7 @@
leal 28(%edx), %eax
pushl %eax /* (sigset_t*)set */
pushl $3 /* SIG_SETMASK */
- call __libc_sigprocmask
+ call __i386_libc_sigprocmask
addl $12,%esp
movl 4(%esp),%edx
movl 8(%esp),%eax
--- src/lib/libc/lib/libc/i386/gen/sigsetjmp.S
+++ src/lib/libc/lib/libc/i386/gen/sigsetjmp.S
@@ -63,7 +63,7 @@
pushl %eax /* (sigset_t*)oset */
pushl $0 /* (sigset_t*)set */
pushl $1 /* SIG_BLOCK */
- call __libc_sigprocmask
+ call __i386_libc_sigprocmask
addl $12,%esp
movl 4(%esp),%ecx
2: movl 0(%esp),%edx
@@ -87,7 +87,7 @@
leal 28(%edx), %eax
pushl %eax /* (sigset_t*)set */
pushl $3 /* SIG_SETMASK */
- call __libc_sigprocmask
+ call __i386_libc_sigprocmask
addl $12,%esp
movl 4(%esp),%edx
2: movl 8(%esp),%eax

111
overlay/libc/default.nix Normal file
View File

@ -0,0 +1,111 @@
# SPDX-FileCopyrightText: Emery Hemingway
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
{ stdenv, fetchgit, fetchurl, genodeHeaders, bison, flex, glibc, writeText }:
let
archInfo = with stdenv.hostPlatform;
if isAarch32 then {
inherit isArm isAarch32;
} else if isAarch64 then {
inherit isArm isAarch64;
} else if isx86_32 then {
inherit isx86 isx86_32;
} else if isx86_64 then {
inherit isx86 isx86_64;
} else
{ };
in stdenv.mkDerivation (archInfo // {
pname = "libgenode";
version = "19.11";
inherit genodeHeaders;
depsBuildBuild = [
bison
flex
glibc # provides rpcgen
];
src = fetchurl {
url =
"http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.0-RELEASE/src.txz";
sha256 = "0da393ac2174168a71c1c527d1453e07372295187d05c288250800cb152a889b";
};
unpackPhase = "tar xf $src $tarFlags";
tarFlags = [
"--strip-components=2"
"usr/src/contrib/gdtoa"
"usr/src/contrib/libc-vis"
"usr/src/contrib/tzcode/stdtime"
"usr/src/include"
"usr/src/lib/libc"
"usr/src/lib/msun"
"usr/src/sys/amd64"
"usr/src/sys/arm"
"usr/src/sys/arm64"
"usr/src/sys/bsm"
"usr/src/sys/crypto/chacha20"
"usr/src/sys/i386"
"usr/src/sys/libkern"
"usr/src/sys/net"
"usr/src/sys/netinet"
"usr/src/sys/netinet6"
"usr/src/sys/riscv"
"usr/src/sys/rpc"
"usr/src/sys/sys"
"usr/src/sys/vm"
"usr/src/sys/x86"
];
patches = [
./cdefs_no_hidden.patch
./_CurrentRuneLocale.patch
./gdtoa.patch
./log2.patch
./MB_CUR_MAX.patch
./mktime.patch
./printfcommon.patch
./rcmd.patch
./res_init_c.patch
./runetype.patch
./semaphore.patch
./thread_local.patch
./types.patch
./vfwprintf_c_warn.patch
./xlocale.patch
./xlocale_private.patch
./xprintf_float.patch
];
patchFlags = "-p0 --strip 3";
genodeRelLd = "${genodeHeaders}/ld/genode_rel.ld";
genodePrgPcIn = ./genode-prg.pc.in;
libcSymbols = ./libc.symbols;
ldSymbols = ./ld.symbols;
linkerLd = ./linker.ld;
vfsSymbols = ./vfs.symbols;
builder = writeText "builder.sh" ''
source $stdenv/setup
export includedir=$out/include
export pkgconfigdir=$out/lib/pkgconfig
export lddir=${genodeHeaders}/ld
mkdir -p $pkgconfigdir $out/lib
source ${./libc-builder.sh}
substituteAll ${./libc.pc.in} $pkgconfigdir/libc.pc
substituteAll ${./vfs.pc.in} $pkgconfigdir/vfs.pc
substituteAll ${./genode-prg.pc.in} $pkgconfigdir/genode-prg.pc
ln -s $out/lib/libc.lib.so $out/lib/libc.so
'';
})

43
overlay/libc/gdtoa.patch Normal file
View File

@ -0,0 +1,43 @@
--- src/lib/libc/contrib/gdtoa/gdtoaimp.h.orig 2019-04-16 11:11:02.420833030 +0200
+++ src/lib/libc/contrib/gdtoa/gdtoaimp.h 2019-04-16 11:11:17.704278981 +0200
@@ -506,40 +506,6 @@
#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
#endif /* NO_STRING_H */
-/*
- * Paranoia: Protect exported symbols, including ones in files we don't
- * compile right now. The standard strtof and strtod survive.
- */
-#define dtoa __dtoa
-#define gdtoa __gdtoa
-#define freedtoa __freedtoa
-#define strtodg __strtodg
-#define g_ddfmt __g_ddfmt
-#define g_dfmt __g_dfmt
-#define g_ffmt __g_ffmt
-#define g_Qfmt __g_Qfmt
-#define g_xfmt __g_xfmt
-#define g_xLfmt __g_xLfmt
-#define strtoId __strtoId
-#define strtoIdd __strtoIdd
-#define strtoIf __strtoIf
-#define strtoIQ __strtoIQ
-#define strtoIx __strtoIx
-#define strtoIxL __strtoIxL
-#define strtord_l __strtord_l
-#define strtordd __strtordd
-#define strtorf __strtorf
-#define strtorQ_l __strtorQ_l
-#define strtorx_l __strtorx_l
-#define strtorxL __strtorxL
-#define strtodI __strtodI
-#define strtopd __strtopd
-#define strtopdd __strtopdd
-#define strtopf __strtopf
-#define strtopQ __strtopQ
-#define strtopx __strtopx
-#define strtopxL __strtopxL
-
/* Protect gdtoa-internal symbols */
#define Balloc __Balloc_D2A
#define Bfree __Bfree_D2A

View File

@ -0,0 +1,7 @@
lddir=@lddir@
Name: genode-prg
Description: Flags for dynamically-linked Genode programs
URL: https://genode.org/
Version: @version@
Libs: -gc-sections -z max-page-size=0x1000 --dynamic-list=${lddir}/genode_dyn.dl -nostdlib -Ttext=0x01000000 --dynamic-linker=ld.lib.so --eh-frame-hdr -rpath-link=. -T${lddir}/genode_dyn.ld -l:ld.lib.so

662
overlay/libc/ld.symbols Normal file
View File

@ -0,0 +1,662 @@
#
# \brief Genode application binary interface (ABI)
# \author Norman Feske
# \date 2016-12-20
#
# This file contains the binary application interface (ABI) provided by
# Genode's dynamic linker. Each line contains the name of a symbol followed
# by its type (according to the encoding used by binutil's 'nm' tool). Data
# symbols are furher annotated by the size of their corresponding data object.
# The latter is only needed on ARM.
#
# On the ARM architecture, copy relocations are created for read-only data
# objects that are present in shared libraries. For each data object, the
# linker preserves a slot in the program's BSS according to the object size.
# At runtime, the dynamic linker copies the data from the shared library's
# read-only segment to these slots. The copy relocations for a given binary
# can be inspected via 'objdump -R'. The size of data symbols as present in a
# shared library (like 'ld-hw.lib.a') can be inspected via 'nm --format posix'.
# The data-object sizes as annotated here must always be at least as big as the
# corresponding data objects present in the dynamic linker.
#
# The original version of this file is based on the output of the
# 'tool/abi_symbols' tool with 'ld-<platform>.lib.so' used as argument.
# However, this tool was solely used as a starting point for the - now
# manually maintained - file.
#
# Note that not all symbols present in this list are provided by each variant
# of the dynamic linker. I.e., there are a few symbols that are specific for a
# particular kernel or the C++ ABI of a specific architecture.
#
# Please keep the file sorted via 'LC_COLLATE=C sort'.
#
#
# Copyright (C) 2016-2019 Genode Labs GmbH
#
# This file is part of the Genode OS framework, which is distributed
# under the terms of the GNU Affero General Public License version 3.
#
_Unwind_Complete T
_Unwind_DeleteException T
_Unwind_Resume T
_Z11genode_exiti T
_Z13genode_atexitPFvvE T
_Z16main_thread_utcbv T
_Z21genode___cxa_finalizePv T
_Z22__ldso_raise_exceptionv T
_ZN5Timer10Connection16schedule_timeoutEN6Genode12MicrosecondsERNS1_11Time_source15Timeout_handlerE T
_ZN5Timer10Connection18_schedule_one_shotERN6Genode7TimeoutENS1_12MicrosecondsE T
_ZN5Timer10Connection18_schedule_periodicERN6Genode7TimeoutENS1_12MicrosecondsE T
_ZN5Timer10Connection8_discardERN6Genode7TimeoutE T
_ZN5Timer10Connection9curr_timeEv T
_ZN5Timer10ConnectionC1ERN6Genode3EnvEPKc T
_ZN5Timer10ConnectionC2ERN6Genode3EnvEPKc T
_ZN5Timer10ConnectionC1ERN6Genode3EnvERNS1_10EntrypointEPKc T
_ZN5Timer10ConnectionC2ERN6Genode3EnvERNS1_10EntrypointEPKc T
_ZN6Genode10Entrypoint16_dispatch_signalERNS_6SignalE T
_ZN6Genode10Entrypoint16schedule_suspendEPFvvES2_ T
_ZN6Genode10Entrypoint22Signal_proxy_component6signalEv T
_ZN6Genode10Entrypoint25_process_incoming_signalsEv T
_ZN6Genode10Entrypoint32_wait_and_dispatch_one_io_signalEb T
_ZN6Genode10Entrypoint6manageERNS_22Signal_dispatcher_baseE T
_ZN6Genode10Entrypoint8dissolveERNS_22Signal_dispatcher_baseE T
_ZN6Genode10EntrypointC1ERNS_3EnvE T
_ZN6Genode10EntrypointC1ERNS_3EnvEmPKcNS_8Affinity8LocationE T
_ZN6Genode10EntrypointC2ERNS_3EnvEmPKcNS_8Affinity8LocationE T
_ZN6Genode10EntrypointD1Ev T
_ZN6Genode10EntrypointD2Ev T
_ZN6Genode10Ipc_serverC1Ev T
_ZN6Genode10Ipc_serverC2Ev T
_ZN6Genode10Ipc_serverD1Ev T
_ZN6Genode10Ipc_serverD2Ev T
_ZN6Genode10Vm_sessionD0Ev T
_ZN6Genode10Vm_sessionD2Ev T
_ZN6Genode11Sliced_heap4freeEPvm T
_ZN6Genode11Sliced_heap5allocEmPPv T
_ZN6Genode11Sliced_heapC1ERNS_13Ram_allocatorERNS_10Region_mapE T
_ZN6Genode11Sliced_heapC2ERNS_13Ram_allocatorERNS_10Region_mapE T
_ZN6Genode11Sliced_heapD0Ev T
_ZN6Genode11Sliced_heapD1Ev T
_ZN6Genode11Sliced_heapD2Ev T
_ZN6Genode12Address_infoC1Em T
_ZN6Genode12Address_infoC2Em T
_ZN6Genode12Trace_output12trace_outputEv T
_ZN6Genode12Trace_output8_acquireEv T
_ZN6Genode12Trace_output8_releaseEv T
_ZN6Genode13Avl_node_base15_rotate_subtreeEPS0_bRNS0_6PolicyE T
_ZN6Genode13Avl_node_base18_rebalance_subtreeEPS0_RNS0_6PolicyE T
_ZN6Genode13Avl_node_base6_adoptEPS0_bRNS0_6PolicyE T
_ZN6Genode13Avl_node_base6insertEPS0_RNS0_6PolicyE T
_ZN6Genode13Avl_node_base6removeERNS0_6PolicyE T
_ZN6Genode13Avl_node_baseC1Ev T
_ZN6Genode13Avl_node_baseC2Ev T
_ZN6Genode13Registry_base7ElementC1ERS0_Pv T
_ZN6Genode13Registry_base7ElementC2ERS0_Pv T
_ZN6Genode13Registry_base7ElementD1Ev T
_ZN6Genode13Registry_base7ElementD2Ev T
_ZN6Genode13Registry_base7_insertERNS0_7ElementE T
_ZN6Genode13Registry_base7_removeERNS0_7ElementE T
_ZN6Genode13Registry_base9_for_eachERNS0_15Untyped_functorE T
_ZN6Genode13Session_state7destroyEv T
_ZN6Genode13Session_stateC1ERNS_7ServiceERNS_8Id_spaceINS_6Parent6ClientEEENS6_2IdERKNS_13Session_labelERKNS_6StringILm256EEERKNS_8AffinityE T
_ZN6Genode13Session_stateC2ERNS_7ServiceERNS_8Id_spaceINS_6Parent6ClientEEENS6_2IdERKNS_13Session_labelERKNS_6StringILm256EEERKNS_8AffinityE T
_ZN6Genode13Shared_objectC1ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
_ZN6Genode13Shared_objectC2ERNS_3EnvERNS_9AllocatorEPKcNS0_4BindENS0_4KeepE T
_ZN6Genode13Shared_objectD1Ev T
_ZN6Genode13Shared_objectD2Ev T
_ZN6Genode13sleep_foreverEv T
_ZN6Genode14Capability_map6insertEmm T
_ZN6Genode14Dynamic_linker23_for_each_loaded_objectERNS_3EnvERKNS0_11For_each_fnE T
_ZN6Genode14Dynamic_linker4keepERNS_3EnvEPKc T
_ZN6Genode14Dynamic_linker8_respawnERNS_3EnvEPKcS4_ T
_ZN6Genode14Rpc_entrypoint13_free_rpc_capERNS_10Pd_sessionENS_17Native_capabilityE T
_ZN6Genode14Rpc_entrypoint14_alloc_rpc_capERNS_10Pd_sessionENS_17Native_capabilityEm T
_ZN6Genode14Rpc_entrypoint17_activation_entryEv T
_ZN6Genode14Rpc_entrypoint17reply_signal_infoENS_17Native_capabilityEmm T
_ZN6Genode14Rpc_entrypoint22_block_until_cap_validEv T
_ZN6Genode14Rpc_entrypoint5entryEv T
_ZN6Genode14Rpc_entrypoint7_manageEPNS_15Rpc_object_baseE T
_ZN6Genode14Rpc_entrypoint8activateEv T
_ZN6Genode14Rpc_entrypoint9_dissolveEPNS_15Rpc_object_baseE T
_ZN6Genode14Rpc_entrypointC1EPNS_10Pd_sessionEmPKcbNS_8Affinity8LocationE T
_ZN6Genode14Rpc_entrypointC2EPNS_10Pd_sessionEmPKcbNS_8Affinity8LocationE T
_ZN6Genode14Rpc_entrypointD0Ev T
_ZN6Genode14Rpc_entrypointD1Ev T
_ZN6Genode14Rpc_entrypointD2Ev T
_ZN6Genode14Signal_contextD0Ev T
_ZN6Genode14Signal_contextD1Ev T
_ZN6Genode14Signal_contextD2Ev T
_ZN6Genode14cache_coherentEmm T
_ZN6Genode14env_deprecatedEv T
_ZN6Genode14ipc_reply_waitERKNS_17Native_capabilityENS_18Rpc_exception_codeERNS_11Msgbuf_baseES5_ T
_ZN6Genode15Alarm_scheduler12_setup_alarmERNS_5AlarmEmm T
_ZN6Genode15Alarm_scheduler13next_deadlineEPm T
_ZN6Genode15Alarm_scheduler17schedule_absoluteEPNS_5AlarmEy T
_ZN6Genode15Alarm_scheduler18_get_pending_alarmEv T
_ZN6Genode15Alarm_scheduler23_unsynchronized_dequeueEPNS_5AlarmE T
_ZN6Genode15Alarm_scheduler23_unsynchronized_enqueueEPNS_5AlarmE T
_ZN6Genode15Alarm_scheduler6handleEy T
_ZN6Genode15Alarm_scheduler7discardEPNS_5AlarmE T
_ZN6Genode15Alarm_scheduler8scheduleEPNS_5AlarmEm T
_ZN6Genode15Alarm_schedulerD1Ev T
_ZN6Genode15Alarm_schedulerD2Ev T
_ZN6Genode15Cancelable_lock4lockEv T
_ZN6Genode15Cancelable_lock6unlockEv T
_ZN6Genode15Cancelable_lock9Applicant7wake_upEv T
_ZN6Genode15Cancelable_lockC1ENS0_5StateE T
_ZN6Genode15Cancelable_lockC2ENS0_5StateE T
_ZN6Genode15Connection_baseC1Ev T
_ZN6Genode15Connection_baseC2Ev T
_ZN6Genode15Signal_receiver12local_submitENS_6Signal4DataE T
_ZN6Genode15Signal_receiver14pending_signalEv T
_ZN6Genode15Signal_receiver15wait_for_signalEv T
_ZN6Genode15Signal_receiver16block_for_signalEv T
_ZN6Genode15Signal_receiver6manageEPNS_14Signal_contextE T
_ZN6Genode15Signal_receiver8dissolveEPNS_14Signal_contextE T
_ZN6Genode15Signal_receiverC1Ev T
_ZN6Genode15Signal_receiverC2Ev T
_ZN6Genode15Signal_receiverD1Ev T
_ZN6Genode15Signal_receiverD2Ev T
_ZN6Genode16raw_write_stringEPKc T
_ZN6Genode17Native_capability4_decEv T
_ZN6Genode17Native_capability4_incEv T
_ZN6Genode17Native_capabilityC1Ev T
_ZN6Genode17Native_capabilityC2Ev T
_ZN6Genode17Region_map_client13fault_handlerENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode17Region_map_client5stateEv T
_ZN6Genode17Region_map_client6attachENS_10CapabilityINS_9DataspaceEEEmlbNS_10Region_map10Local_addrEbb T
_ZN6Genode17Region_map_client6detachENS_10Region_map10Local_addrE T
_ZN6Genode17Region_map_client9dataspaceEv T
_ZN6Genode17Region_map_clientC1ENS_10CapabilityINS_10Region_mapEEE T
_ZN6Genode17Region_map_clientC2ENS_10CapabilityINS_10Region_mapEEE T
_ZN6Genode17Rm_session_client6createEm T
_ZN6Genode17Rm_session_client7destroyENS_10CapabilityINS_10Region_mapEEE T
_ZN6Genode17Rm_session_clientC1ENS_10CapabilityINS_10Rm_sessionEEE T
_ZN6Genode17Rm_session_clientC2ENS_10CapabilityINS_10Rm_sessionEEE T
_ZN6Genode17Vm_session_client11create_vcpuERNS_9AllocatorERNS_3EnvERNS_15Vm_handler_baseE T
_ZN6Genode17Vm_session_client3runENS_10Vm_session7Vcpu_idE T
_ZN6Genode17Vm_session_client5pauseENS_10Vm_session7Vcpu_idE T
_ZN6Genode17Vm_session_client9cpu_stateENS_10Vm_session7Vcpu_idE T
_ZN6Genode18Allocator_avl_base10_add_blockEPNS0_5BlockEmmb T
_ZN6Genode18Allocator_avl_base10alloc_addrEmm T
_ZN6Genode18Allocator_avl_base12remove_rangeEmm T
_ZN6Genode18Allocator_avl_base13alloc_alignedEmPPvimm T
_ZN6Genode18Allocator_avl_base14_destroy_blockEPNS0_5BlockE T
_ZN6Genode18Allocator_avl_base14any_block_addrEPm T
_ZN6Genode18Allocator_avl_base15_cut_from_blockEPNS0_5BlockEmmS2_S2_ T
_ZN6Genode18Allocator_avl_base20_find_any_used_blockEPNS0_5BlockE T
_ZN6Genode18Allocator_avl_base21_alloc_block_metadataEv T
_ZN6Genode18Allocator_avl_base26_alloc_two_blocks_metadataEPPNS0_5BlockES3_ T
_ZN6Genode18Allocator_avl_base30_revert_allocations_and_rangesEv T
_ZN6Genode18Allocator_avl_base4freeEPv T
_ZN6Genode18Allocator_avl_base5Block13find_best_fitEmjmm T
_ZN6Genode18Allocator_avl_base5Block15find_by_addressEmmb T
_ZN6Genode18Allocator_avl_base5Block16avail_in_subtreeEv T
_ZN6Genode18Allocator_avl_base5Block9recomputeEv T
_ZN6Genode18Allocator_avl_base9add_rangeEmm T
_ZN6Genode18Signal_transmitter6submitEj T
_ZN6Genode18Signal_transmitter7contextENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode18Signal_transmitter7contextEv T
_ZN6Genode18Signal_transmitterC1ENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode18Signal_transmitterC2ENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode18server_socket_pairEv T
_ZN6Genode20env_session_id_spaceEv T
_ZN6Genode23Alarm_timeout_scheduler14handle_timeoutENS_8DurationE T
_ZN6Genode23Alarm_timeout_scheduler18_schedule_one_shotERNS_7TimeoutENS_12MicrosecondsE T
_ZN6Genode23Alarm_timeout_scheduler18_schedule_periodicERNS_7TimeoutENS_12MicrosecondsE T
_ZN6Genode23Alarm_timeout_scheduler7_enableEv T
_ZN6Genode23Alarm_timeout_schedulerC1ERNS_11Time_sourceENS_12MicrosecondsE T
_ZN6Genode23Alarm_timeout_schedulerC2ERNS_11Time_sourceENS_12MicrosecondsE T
_ZN6Genode23Alarm_timeout_schedulerD0Ev T
_ZN6Genode23Alarm_timeout_schedulerD1Ev T
_ZN6Genode23Alarm_timeout_schedulerD2Ev T
_ZN6Genode25env_stack_area_region_mapE B 8
_ZN6Genode28env_stack_area_ram_allocatorE B 8
_ZN6Genode3Log3logEv T
_ZN6Genode3Log8_acquireENS0_4TypeE T
_ZN6Genode3Log8_releaseEv T
_ZN6Genode3Raw7_outputEv T
_ZN6Genode3Raw8_acquireEv T
_ZN6Genode3Raw8_releaseEv T
_ZN6Genode4Heap11quota_limitEm T
_ZN6Genode4Heap4freeEPvm T
_ZN6Genode4Heap5allocEmPPv T
_ZN6Genode4HeapC1EPNS_13Ram_allocatorEPNS_10Region_mapEmPvm T
_ZN6Genode4HeapC2EPNS_13Ram_allocatorEPNS_10Region_mapEmPvm T
_ZN6Genode4HeapD0Ev T
_ZN6Genode4HeapD1Ev T
_ZN6Genode4HeapD2Ev T
_ZN6Genode4Slab13any_used_elemEv T
_ZN6Genode4Slab5Block11_slab_entryEi T
_ZN6Genode4Slab5Block14any_used_entryEv T
_ZN6Genode4Slab5Block5allocEv T
_ZN6Genode4Slab5Block9inc_availERNS0_5EntryE T
_ZN6Genode4Slab5_freeEPv T
_ZN6Genode4Slab5allocEmPPv T
_ZN6Genode4Slab9insert_sbEPv T
_ZN6Genode4SlabC1EmmPvPNS_9AllocatorE T
_ZN6Genode4SlabC2EmmPvPNS_9AllocatorE T
_ZN6Genode4SlabD0Ev T
_ZN6Genode4SlabD1Ev T
_ZN6Genode4SlabD2Ev T
_ZN6Genode5AlarmD0Ev T
_ZN6Genode5AlarmD1Ev T
_ZN6Genode5AlarmD2Ev T
_ZN6Genode5Child10yield_sighENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode5Child11session_capENS_8Id_spaceINS_6Parent6ClientEE2IdE T
_ZN6Genode5Child12session_sighENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode5Child13session_readyERNS_13Session_stateE T
_ZN6Genode5Child13yield_requestEv T
_ZN6Genode5Child14session_closedERNS_13Session_stateE T
_ZN6Genode5Child14yield_responseEv T
_ZN6Genode5Child16resource_requestERKNS_6StringILm160EEE T
_ZN6Genode5Child16session_responseENS_8Id_spaceINS_6Parent6ServerEE2IdENS2_16Session_responseE T
_ZN6Genode5Child18close_all_sessionsEv T
_ZN6Genode5Child19deliver_session_capENS_8Id_spaceINS_6Parent6ServerEE2IdENS_10CapabilityINS_7SessionEEE T
_ZN6Genode5Child19resource_avail_sighENS_10CapabilityINS_14Signal_contextEEE T
_ZN6Genode5Child21initiate_env_sessionsEv T
_ZN6Genode5Child23initiate_env_pd_sessionEv T
_ZN6Genode5Child4exitEi T
_ZN6Genode5Child5closeENS_8Id_spaceINS_6Parent6ClientEE2IdE T
_ZN6Genode5Child5yieldERKNS_6StringILm160EEE T
_ZN6Genode5Child7sessionENS_8Id_spaceINS_6Parent6ClientEE2IdERKNS_13Rpc_in_bufferILm64EEERKNS6_ILm160EEERKNS_8AffinityE T
_ZN6Genode5Child7upgradeENS_8Id_spaceINS_6Parent6ClientEE2IdERKNS_13Rpc_in_bufferILm160EEE T
_ZN6Genode5Child8announceERKNS_13Rpc_in_bufferILm64EEE T
_ZN6Genode5Child9heartbeatEv T
_ZN6Genode5ChildC1ERNS_10Region_mapERNS_14Rpc_entrypointERNS_12Child_policyE T
_ZN6Genode5ChildC2ERNS_10Region_mapERNS_14Rpc_entrypointERNS_12Child_policyE T
_ZN6Genode5ChildD0Ev T
_ZN6Genode5ChildD1Ev T
_ZN6Genode5ChildD2Ev T
_ZN6Genode5Stack4sizeEm T
_ZN6Genode5Trace6Logger17_evaluate_controlEv T
_ZN6Genode5Trace6Logger3logEPKcm T
_ZN6Genode5Trace6LoggerC1Ev T
_ZN6Genode5Trace6LoggerC2Ev T
_ZN6Genode5printERNS_6OutputEPKc T
_ZN6Genode5printERNS_6OutputEPKv T
_ZN6Genode5printERNS_6OutputEd T
_ZN6Genode5printERNS_6OutputEf T
_ZN6Genode5printERNS_6OutputEl T
_ZN6Genode5printERNS_6OutputEm T
_ZN6Genode5printERNS_6OutputEx T
_ZN6Genode5printERNS_6OutputEy T
_ZN6Genode6Output10out_stringEPKcm T
_ZN6Genode6Parent8announceERKNS_13Rpc_in_bufferILm64EEENS_10CapabilityINS_4RootEEE T
_ZN6Genode6Signal19_dec_ref_and_unlockEv T
_ZN6Genode6Signal8_inc_refEv T
_ZN6Genode6SignalC1ENS0_4DataE T
_ZN6Genode6SignalC1ERKS0_ T
_ZN6Genode6SignalC2ENS0_4DataE T
_ZN6Genode6SignalC2ERKS0_ T
_ZN6Genode6SignalD1Ev T
_ZN6Genode6SignalD2Ev T
_ZN6Genode6SignalaSERKS0_ T
_ZN6Genode6Thread10stack_sizeEm T
_ZN6Genode6Thread13native_threadEv T
_ZN6Genode6Thread15cancel_blockingEv T
_ZN6Genode6Thread18stack_virtual_sizeEv T
_ZN6Genode6Thread20free_secondary_stackEPv T
_ZN6Genode6Thread21alloc_secondary_stackEPKcm T
_ZN6Genode6Thread23stack_area_virtual_baseEv T
_ZN6Genode6Thread23stack_area_virtual_sizeEv T
_ZN6Genode6Thread4joinEv T
_ZN6Genode6Thread4nameEPcm T
_ZN6Genode6Thread4utcbEv T
_ZN6Genode6Thread5startEv T
_ZN6Genode6Thread6myselfEv T
_ZN6Genode6Thread7_loggerEv T
_ZN6Genode6Thread7mystackEv T
_ZN6Genode6ThreadC1ERNS_3EnvERKNS_6StringILm32EEEm T
_ZN6Genode6ThreadC1ERNS_3EnvERKNS_6StringILm32EEEmNS_8Affinity8LocationENS_11Cpu_session6WeightERS9_ T
_ZN6Genode6ThreadC1EmPKcmNS0_4TypeENS_8Affinity8LocationE T
_ZN6Genode6ThreadC1EmPKcmNS0_4TypeEPNS_11Cpu_sessionENS_8Affinity8LocationE T
_ZN6Genode6ThreadC2ERNS_3EnvERKNS_6StringILm32EEEm T
_ZN6Genode6ThreadC2ERNS_3EnvERKNS_6StringILm32EEEmNS_8Affinity8LocationENS_11Cpu_session6WeightERS9_ T
_ZN6Genode6ThreadC2EmPKcmNS0_4TypeENS_8Affinity8LocationE T
_ZN6Genode6ThreadC2EmPKcmNS0_4TypeEPNS_11Cpu_sessionENS_8Affinity8LocationE T
_ZN6Genode6ThreadD0Ev T
_ZN6Genode6ThreadD1Ev T
_ZN6Genode6ThreadD2Ev T
_ZN6Genode7Console11_out_stringEPKc T
_ZN6Genode7Console6printfEPKcz T
_ZN6Genode7Console7vprintfEPKcP13__va_list_tag T
_ZN6Genode7Console7vprintfEPKcPc T
_ZN6Genode7Console7vprintfEPKcPv T
_ZN6Genode7Console7vprintfEPKcSt9__va_list T
_ZN6Genode7Timeout17schedule_one_shotENS_12MicrosecondsERNS0_7HandlerE T
_ZN6Genode7Timeout17schedule_periodicENS_12MicrosecondsERNS0_7HandlerE T
_ZN6Genode7Timeout5AlarmD0Ev T
_ZN6Genode7Timeout5AlarmD1Ev T
_ZN6Genode7Timeout5AlarmD2Ev T
_ZN6Genode7Timeout7discardEv T
_ZN6Genode7cap_mapEv T
_ZN6Genode8Duration3addENS_12MicrosecondsE T
_ZN6Genode8Duration3addENS_12MillisecondsE T
_ZN6Genode8ipc_callENS_17Native_capabilityERNS_11Msgbuf_baseES2_m T
_ZN6Genode9ipc_replyENS_17Native_capabilityENS_18Rpc_exception_codeERNS_11Msgbuf_baseE T
_ZNK10__cxxabiv117__class_type_info10__do_catchEPKSt9type_infoPPvj T
_ZNK10__cxxabiv120__si_class_type_info11__do_upcastEPKNS_17__class_type_infoEPKvRNS1_15__upcast_resultE T
_ZNK10__cxxabiv120__si_class_type_info12__do_dyncastElNS_17__class_type_info10__sub_kindEPKS1_PKvS4_S6_RNS1_16__dyncast_resultE T
_ZNK10__cxxabiv120__si_class_type_info20__do_find_public_srcElPKvPKNS_17__class_type_infoES2_ T
_ZNK6Genode11Sliced_heap8overheadEm T
_ZNK6Genode13Session_state24generate_session_requestERNS_13Xml_generatorE T
_ZNK6Genode13Session_state25generate_client_side_infoERNS_13Xml_generatorENS0_6DetailE T
_ZNK6Genode13Session_state25generate_server_side_infoERNS_13Xml_generatorENS0_6DetailE T
_ZNK6Genode13Session_state5printERNS_6OutputE T
_ZNK6Genode13Shared_object7_lookupEPKc T
_ZNK6Genode13Shared_object8link_mapEv T
_ZNK6Genode14Rpc_entrypoint9is_myselfEv T
_ZNK6Genode17Native_capability10local_nameEv T
_ZNK6Genode17Native_capability3rawEv T
_ZNK6Genode17Native_capability5printERNS_6OutputE T
_ZNK6Genode17Native_capability5validEv T
_ZNK6Genode18Allocator_avl_base10valid_addrEm T
_ZNK6Genode18Allocator_avl_base5availEv T
_ZNK6Genode18Allocator_avl_base7size_atEPKv T
_ZNK6Genode3Hex5printERNS_6OutputE T
_ZNK6Genode4Slab8consumedEv T
_ZNK6Genode5Child15main_thread_capEv T
_ZNK6Genode5Child18skipped_heartbeatsEv T
_ZNK6Genode5Child21notify_resource_availEv T
_ZNK6Genode6Thread10stack_baseEv T
_ZNK6Genode6Thread4nameEv T
_ZNK6Genode6Thread9stack_topEv T
_ZNK6Genode8Duration17trunc_to_plain_msEv T
_ZNK6Genode8Duration17trunc_to_plain_usEv T
_ZNK6Genode8Duration9less_thanERKS0_ T
_ZNKSt13bad_exception4whatEv T
_ZNKSt9exception4whatEv T
_ZNSt13bad_exceptionD0Ev T
_ZNSt13bad_exceptionD1Ev T
_ZNSt13bad_exceptionD2Ev T
_ZNSt9exceptionD0Ev T
_ZNSt9exceptionD1Ev T
_ZNSt9exceptionD2Ev T
_ZSt18uncaught_exceptionv T
_ZSt19uncaught_exceptionsv T
_ZSt9terminatev T
_ZTIDd D 16
_ZTIDe D 16
_ZTIDf D 16
_ZTIDi D 16
_ZTIDn D 16
_ZTIDs D 16
_ZTIN10__cxxabiv115__forced_unwindE D 16
_ZTIN10__cxxabiv116__enum_type_infoE D 24
_ZTIN10__cxxabiv117__class_type_infoE D 24
_ZTIN10__cxxabiv117__pbase_type_infoE D 24
_ZTIN10__cxxabiv119__foreign_exceptionE D 16
_ZTIN10__cxxabiv119__pointer_type_infoE D 24
_ZTIN10__cxxabiv120__function_type_infoE D 24
_ZTIN10__cxxabiv120__si_class_type_infoE D 24
_ZTIN10__cxxabiv121__vmi_class_type_infoE D 24
_ZTIN10__cxxabiv123__fundamental_type_infoE D 24
_ZTIN5Timer10ConnectionE D 88
_ZTIN6Genode10Vm_sessionE D 24
_ZTIN6Genode11Sliced_heapE D 24
_ZTIN6Genode14Rpc_entrypointE D 56
_ZTIN6Genode14Signal_contextE D 56
_ZTIN6Genode17Region_map_clientE D 24
_ZTIN6Genode17Rm_session_clientE D 24
_ZTIN6Genode18Allocator_avl_baseE D 24
_ZTIN6Genode23Alarm_timeout_schedulerE D 72
_ZTIN6Genode4HeapE D 24
_ZTIN6Genode4SlabE D 24
_ZTIN6Genode5AlarmE D 16
_ZTIN6Genode5Child14Initial_threadE D 24
_ZTIN6Genode5ChildE D 72
_ZTIN6Genode6OutputE D 24
_ZTIN6Genode6ThreadE D 16
_ZTIN6Genode7ConsoleE D 16
_ZTIN6Genode7Timeout5AlarmE D 16
_ZTIPDd D 32
_ZTIPDe D 32
_ZTIPDf D 32
_ZTIPDi D 32
_ZTIPDn D 32
_ZTIPDs D 32
_ZTIPKDd D 32
_ZTIPKDe D 32
_ZTIPKDf D 32
_ZTIPKDi D 32
_ZTIPKDn D 32
_ZTIPKDs D 32
_ZTIPKa D 32
_ZTIPKb D 32
_ZTIPKc D 32
_ZTIPKd D 32
_ZTIPKe D 32
_ZTIPKf D 32
_ZTIPKh D 32
_ZTIPKi D 32
_ZTIPKj D 32
_ZTIPKl D 32
_ZTIPKm D 32
_ZTIPKs D 32
_ZTIPKt D 32
_ZTIPKx D 32
_ZTIPKy D 32
_ZTIPVKa D 32
_ZTIPVKb D 32
_ZTIPVKc D 32
_ZTIPVKd D 32
_ZTIPVKe D 32
_ZTIPVKf D 32
_ZTIPVKh D 32
_ZTIPVKi D 32
_ZTIPVKj D 32
_ZTIPVKl D 32
_ZTIPVKm D 32
_ZTIPVKs D 32
_ZTIPVKt D 32
_ZTIPVKx D 32
_ZTIPVKy D 32
_ZTIPVa D 32
_ZTIPVb D 32
_ZTIPVc D 32
_ZTIPVd D 32
_ZTIPVe D 32
_ZTIPVf D 32
_ZTIPVh D 32
_ZTIPVi D 32
_ZTIPVj D 32
_ZTIPVl D 32
_ZTIPVm D 32
_ZTIPVs D 32
_ZTIPVt D 32
_ZTIPVx D 32
_ZTIPVy D 32
_ZTIPa D 32
_ZTIPb D 32
_ZTIPc D 32
_ZTIPd D 32
_ZTIPe D 32
_ZTIPf D 32
_ZTIPh D 32
_ZTIPi D 32
_ZTIPj D 32
_ZTIPl D 32
_ZTIPm D 32
_ZTIPs D 32
_ZTIPt D 32
_ZTIPx D 32
_ZTIPy D 32
_ZTISt10bad_typeid D 24
_ZTISt13bad_exception D 24
_ZTISt16bad_array_length D 24
_ZTISt20bad_array_new_length D 24
_ZTISt8bad_cast D 24
_ZTISt9bad_alloc D 24
_ZTISt9exception D 16
_ZTISt9type_info D 16
_ZTIa D 32
_ZTIb D 32
_ZTIc D 32
_ZTId D 32
_ZTIe D 32
_ZTIf D 32
_ZTIh D 32
_ZTIi D 32
_ZTIj D 32
_ZTIl D 32
_ZTIm D 32
_ZTIs D 32
_ZTIt D 32
_ZTIx D 32
_ZTIy D 32
_ZTSN10__cxxabiv115__forced_unwindE R 32
_ZTSN10__cxxabiv116__enum_type_infoE R 33
_ZTSN10__cxxabiv117__class_type_infoE R 34
_ZTSN10__cxxabiv117__pbase_type_infoE R 34
_ZTSN10__cxxabiv119__foreign_exceptionE R 36
_ZTSN10__cxxabiv119__pointer_type_infoE R 36
_ZTSN10__cxxabiv120__function_type_infoE R 37
_ZTSN10__cxxabiv120__si_class_type_infoE R 37
_ZTSN10__cxxabiv121__vmi_class_type_infoE R 38
_ZTSN10__cxxabiv123__fundamental_type_infoE R 40
_ZTSN5Timer10ConnectionE R 21
_ZTSN6Genode11Sliced_heapE R 23
_ZTSN6Genode14Rpc_entrypointE R 26
_ZTSN6Genode14Signal_contextE R 26
_ZTSN6Genode17Region_map_clientE R 29
_ZTSN6Genode17Rm_session_clientE R 29
_ZTSN6Genode18Allocator_avl_baseE R 30
_ZTSN6Genode23Alarm_timeout_schedulerE R 35
_ZTSN6Genode4HeapE R 15
_ZTSN6Genode4SlabE R 15
_ZTSN6Genode5AlarmE R 16
_ZTSN6Genode5Child14Initial_threadE R 32
_ZTSN6Genode5ChildE R 16
_ZTSN6Genode6OutputE R 17
_ZTSN6Genode6ThreadE R 17
_ZTSN6Genode7ConsoleE R 18
_ZTSN6Genode7Timeout5AlarmE R 24
_ZTSSt10bad_typeid R 15
_ZTSSt13bad_exception R 18
_ZTSSt16bad_array_length R 21
_ZTSSt20bad_array_new_length R 25
_ZTSSt8bad_cast R 12
_ZTSSt9bad_alloc R 13
_ZTSSt9exception R 13
_ZTSSt9type_info R 13
_ZTVN10__cxxabiv115__forced_unwindE D 40
_ZTVN10__cxxabiv116__enum_type_infoE D 64
_ZTVN10__cxxabiv117__class_type_infoE D 88
_ZTVN10__cxxabiv117__pbase_type_infoE D 72
_ZTVN10__cxxabiv119__foreign_exceptionE D 40
_ZTVN10__cxxabiv119__pointer_type_infoE D 72
_ZTVN10__cxxabiv120__function_type_infoE D 64
_ZTVN10__cxxabiv120__si_class_type_infoE D 88
_ZTVN10__cxxabiv121__vmi_class_type_infoE D 88
_ZTVN10__cxxabiv123__fundamental_type_infoE D 64
_ZTVN5Timer10ConnectionE D 320
_ZTVN6Genode10Vm_sessionE D 56
_ZTVN6Genode11Sliced_heapE D 72
_ZTVN6Genode14Rpc_entrypointE D 80
_ZTVN6Genode14Signal_contextE D 32
_ZTVN6Genode17Region_map_clientE D 72
_ZTVN6Genode17Rm_session_clientE D 48
_ZTVN6Genode18Allocator_avl_baseE D 128
_ZTVN6Genode23Alarm_timeout_schedulerE D 112
_ZTVN6Genode4HeapE D 72
_ZTVN6Genode4SlabE D 72
_ZTVN6Genode5AlarmE D 40
_ZTVN6Genode5Child14Initial_threadE D 48
_ZTVN6Genode5ChildE D 440
_ZTVN6Genode6OutputE D 48
_ZTVN6Genode6ThreadE D 48
_ZTVN6Genode7ConsoleE D 48
_ZTVN6Genode7Timeout5AlarmE D 32
_ZTVSt10bad_typeid D 40
_ZTVSt13bad_exception D 40
_ZTVSt16bad_array_length D 40
_ZTVSt20bad_array_new_length D 40
_ZTVSt8bad_cast D 40
_ZTVSt9bad_alloc D 40
_ZTVSt9exception D 40
_ZTVSt9type_info D 64
_ZThn236_N5Timer10Connection16schedule_timeoutEN6Genode12MicrosecondsERNS1_11Time_source15Timeout_handlerE T
_ZThn236_N5Timer10Connection9curr_timeEv T
_ZThn240_N5Timer10Connection18_schedule_one_shotERN6Genode7TimeoutENS1_12MicrosecondsE T
_ZThn240_N5Timer10Connection18_schedule_periodicERN6Genode7TimeoutENS1_12MicrosecondsE T
_ZThn240_N5Timer10Connection8_discardERN6Genode7TimeoutE T
_ZThn240_N5Timer10Connection9curr_timeEv T
_ZThn288_N5Timer10Connection16schedule_timeoutEN6Genode12MicrosecondsERNS1_11Time_source15Timeout_handlerE T
_ZThn288_N5Timer10Connection9curr_timeEv T
_ZThn296_N5Timer10Connection18_schedule_one_shotERN6Genode7TimeoutENS1_12MicrosecondsE T
_ZThn296_N5Timer10Connection18_schedule_periodicERN6Genode7TimeoutENS1_12MicrosecondsE T
_ZThn296_N5Timer10Connection8_discardERN6Genode7TimeoutE T
_ZThn296_N5Timer10Connection9curr_timeEv T
_ZThn4_N6Genode23Alarm_timeout_scheduler14handle_timeoutENS_8DurationE T
_ZThn8_N6Genode23Alarm_timeout_scheduler14handle_timeoutENS_8DurationE T
_ZThn8_N6Genode23Alarm_timeout_schedulerD0Ev T
_ZThn8_N6Genode23Alarm_timeout_schedulerD1Ev T
_ZdlPv W
_ZdlPvPN6Genode11DeallocatorE T
_ZdlPvPN6Genode9AllocatorE W
_ZdlPvRN6Genode11DeallocatorE T
_ZdlPvRN6Genode9AllocatorE W
_ZdlPvm W
_ZnajPN6Genode9AllocatorE T
_ZnajRN6Genode9AllocatorE T
_ZnamPN6Genode9AllocatorE T
_ZnamRN6Genode9AllocatorE T
_ZnwjPN6Genode9AllocatorE T
_ZnwjRN6Genode9AllocatorE T
_ZnwmPN6Genode9AllocatorE T
_ZnwmRN6Genode9AllocatorE T
__aeabi_atexit T
__aeabi_unwind_cpp_pr0 T
__aeabi_unwind_cpp_pr1 T
__cxa_allocate_dependent_exception T
__cxa_allocate_exception T
__cxa_atexit T
__cxa_bad_cast T
__cxa_bad_typeid T
__cxa_begin_catch T
__cxa_begin_cleanup T
__cxa_call_terminate T
__cxa_call_unexpected T
__cxa_current_exception_type T
__cxa_demangle T
__cxa_end_catch T
__cxa_end_cleanup T
__cxa_finalize T
__cxa_free_dependent_exception T
__cxa_free_exception T
__cxa_get_exception_ptr T
__cxa_get_globals T
__cxa_get_globals_fast T
__cxa_guard_abort T
__cxa_guard_acquire T
__cxa_guard_release T
__cxa_pure_virtual T
__cxa_rethrow T
__cxa_throw T
__cxa_throw_bad_array_length T
__cxa_throw_bad_array_new_length T
__cxa_type_match T
__dynamic_cast T
__emutls_get_address T
__gxx_personality_v0 T
__stack_chk_fail W
__stack_chk_guard B 8
dl_iterate_phdr T
dl_unwind_find_exidx T
genode_argc D 4
genode_argv D 8
genode_envp B 8
longjmp W
lx_environ B 8
memcmp W
memcpy W
memmove W
memset W
setjmp W
stdout_reconnect T
strcmp W
strlen W
wait_for_continue T

298
overlay/libc/libc-builder.sh Executable file
View File

@ -0,0 +1,298 @@
compileStub() {
sed \
-e "s/^\(\w\+\) D \(\w\+\)\$/.data; .global \1; .type \1,%object; .size \1,\2; \1: .skip 1/" \
-e "s/^\(\w\+\) V/.data; .weak \1; .type \1,%object; \1: .skip 1/" \
-e "s/^\(\w\+\) T/.text; .global \1; .type \1,%function; \1:/" \
-e "s/^\(\w\+\) R \(\w\+\)\$/.section .rodata; .global \1; .type \1,%object; .size \1,\2; \1:/" \
-e "s/^\(\w\+\) W/.text; .weak \1; .type \1,%function; \1:/" \
-e "s/^\(\w\+\) B \(\w\+\)\$/.bss; .global \1; .type \1,%object; .size \1,\2; \1:/" \
-e "s/^\(\w\+\) U/.text; .global \1; movq \1@GOTPCREL(%rip), %rax/" \
$1 > symbols.s
$CC -x assembler -c symbols.s -o tmp.o
$LD -o $2 \
-shared \
-T$genodeRelLd \
tmp.o
rm tmp.o symbols.s
}
compileLd() {
sed \
-e "s/^\(\w\+\) D \(\w\+\)\$/.data; .global \1; .type \1,%object; .size \1,\2; \1: .skip 1/" \
-e "s/^\(\w\+\) V/.data; .weak \1; .type \1,%object; \1: .skip 1/" \
-e "s/^\(\w\+\) T/.text; .global \1; .type \1,%function; \1:/" \
-e "s/^\(\w\+\) R \(\w\+\)\$/.section .rodata; .global \1; .type \1,%object; .size \1,\2; \1:/" \
-e "s/^\(\w\+\) W/.text; .weak \1; .type \1,%function; \1:/" \
-e "s/^\(\w\+\) B \(\w\+\)\$/.bss; .global \1; .type \1,%object; .size \1,\2; \1:/" \
-e "s/^\(\w\+\) U/.text; .global \1; movq \1@GOTPCREL(%rip), %rax/" \
< $ldSymbols \
> ld.symbols.s
$CXX ${cxxFlags} -c ld.symbols.s -o ld.symbols.o
$LD -o $1 \
-shared \
--eh-frame-hdr \
-z max-page-size=0x1000 \
-T$linkerLd \
-T$genodeRelLd \
ld.symbols.o
}
# Add a prefix to the following arguments
#
addPrefix() {
local prefix=$1
local files=""
for (( i = 2; i <= $#; i++)); do
files="$files $prefix${!i}"
done
echo -n $files
}
#
# Copy into dest the following arguments,
# rooted at $includedir
#
copyIncludes() {
local to=$1; shift
local from=$1; shift
mkdir -p $to
for i in $*; do
cp $from/$i $to/
done
}
#
# CPU-architecture-specific headers
#
# The 'common_include_*_content' functions take the CPU architecture as first
# argument.
#
common_include_libc_arch_content() {
local content
for i in stdarg.h float.h
do content="$content sys/$1/include/$i"; done
for i in arith.h _fpmath.h SYS.h gd_qnan.h
do content="$content lib/libc/$2/$i"; done
echo -n $content
}
common_include_libc_arch_machine_content() {
for i in \
_types.h endian.h _limits.h signal.h trap.h _stdint.h \
sysarch.h ieeefp.h frame.h vm.h \
cpufunc.h vmparam.h atomic.h elf.h exec.h reloc.h pmap.h \
ucontext.h setjmp.h asm.h param.h _inttypes.h _align.h float.h
do echo sys/$1/include/$i; done
}
rpcgen_() {
rpcgen -C -h -DWANT_NFS3 $1 -o $2
}
installPhase() {
mkdir -p $includedir/machine
#
# CPU-architecture-specific headers
#
#
# x86-specific headers
#
if [ -n "${isx86:-}" ]; then
cp lib/msun/x86/fenv.h $includedir
cp -r sys/x86/include $includedir/x86
fi
#
# i386-specific headers
#
if [ -n "${isx86_32:-}" ]; then
cp \
$(common_include_libc_arch_content i386 i386) \
$includedir
cp \
$(common_include_libc_arch_machine_content i386) \
sys/i386/include/specialreg.h \
sys/i386/include/npx.h \
$includedir/machine
fi
#
# AMD64-specific headers
#
if [ -n "${isx86_64:-}" ]; then
cp \
$(common_include_libc_arch_content amd64 amd64) \
$includedir
cp \
$(common_include_libc_arch_machine_content amd64) \
sys/amd64/include/specialreg.h \
sys/amd64/include/fpu.h \
$includedir/machine
fi
#
# ARM-specific headers
#
if [ -n "${isAarch32:-}" ]; then
cp \
$(common_include_libc_arch_content arm arm) \
lib/msun/arm/fenv.h \
$includedir
cp \
$(common_include_libc_arch_machine_content arm) \
$includedir/machine
copyIncludes $includedir/machine sys/arm/include \
armreg.h atomic-v6.h ieee.h sysreg.h
fi
#
# ARM64-specific headers
#
if [ -n "${isAarch32:-}" ]; then
cp \
$(common_include_libc_arch_content arm64 aarch64) \
lib/msun/aarch64/fenv.h \
$includedir
cp \
$(common_include_libc_arch_machine_content arm64) \
$includedir/machine
copyIncludes $includedir/machine sys/arm64/include/ \
armreg.h
fi
##############################################################
flex -P_nsyy -t lib/libc/net/nslexer.l \
| sed -e '/YY_BUF_SIZE/s/16384/1024/' \
> lib/libc/net/nslexer.c
bison -d -p_nsyy lib/libc/net/nsparser.y \
--defines=lib/libc/net/nsparser.h \
--output=lib/libc/net/nsparser.c
local generated_files="include/rpc/rpcb_prot.h"
for h in \
bootparam_prot.h nfs_prot.h nlm_prot.h rstat.h ypupdate_prot.h \
crypt.h nis_cache.h pmap_prot.h rwall.h yp.h \
key_prot.h nis_callback.h rex.h sm_inter.h ypxfrd.h \
klm_prot.h nis_object.h rnusers.h spray.h \
mount.h nis.h rquota.h yppasswd.h
do generated_files="$generated_files include/rpcsvc/$h"; done
for file in $generated_files; do
rpcgen -C -h -DWANT_NFS3 ${file%h}x -o $file
done
#
# Generic headers
#
copyIncludes $includedir include \
strings.h limits.h string.h ctype.h _ctype.h \
stdlib.h stdio.h signal.h unistd.h wchar.h time.h sysexits.h \
resolv.h wctype.h locale.h langinfo.h regex.h paths.h ieeefp.h \
inttypes.h fstab.h netdb.h ar.h memory.h res_update.h \
netconfig.h ifaddrs.h pthread.h err.h getopt.h search.h \
varargs.h stddef.h stdbool.h assert.h monetary.h printf.h \
libgen.h dirent.h dlfcn.h link.h fmtmsg.h fnmatch.h fts.h ftw.h \
db.h grp.h nsswitch.h pthread_np.h pwd.h ttyent.h \
stringlist.h glob.h a.out.h elf-hints.h nlist.h spawn.h \
readpassphrase.h setjmp.h elf.h ulimit.h utime.h wordexp.h \
complex.h semaphore.h uchar.h iconv.h termios.h \
xlocale.h runetype.h \
copyIncludes $includedir sys/sys \
syslog.h fcntl.h stdint.h sched.h ktrace.h _semaphore.h ucontext.h errno.h
cp lib/msun/src/math.h $includedir
cp contrib/libc-vis/vis.h $includedir
copyIncludes $includedir/rpc include/rpc \
rpc.h xdr.h auth.h clnt_stat.h clnt.h clnt_soc.h rpc_msg.h \
auth_unix.h auth_des.h svc.h svc_soc.h svc_auth.h pmap_clnt.h \
pmap_prot.h rpcb_clnt.h rpcent.h des_crypt.h des.h nettype.h \
rpcsec_gss.h raw.h rpc_com.h
cp sys/rpc/rpcb_prot.h $includedir/rpc
copyIncludes $includedir/rpcsvc include/rpcsvc \
yp_prot.h ypclnt.h nis_tags.h nislib.h
rpcgen_ include/rpcsvc/nis.x $includedir/rpcsvc/nis.h
rpcgen_ include/rpcsvc/crypt.x $includedir/rpcsvc/crypt.h
mkdir $includedir/gssapi
cp include/gssapi/gssapi.h $includedir/gssapi
copyIncludes $includedir/arpa include/arpa \
inet.h ftp.h nameser.h nameser_compat.h telnet.h tftp.h
copyIncludes $includedir/vm sys/vm vm_param.h vm.h pmap.h
copyIncludes $includedir/net sys/net \
if.h if_dl.h if_tun.h if_types.h radix.h route.h
copyIncludes $includedir/netinet sys/netinet \
in.h in_systm.h ip.h tcp.h
mkdir -p $includedir/netinet6
cp sys/netinet6/in6.h $includedir/netinet6
mkdir -p $includedir/bsm
cp sys/bsm/audit.h $includedir/bsm
copyIncludes $includedir/sys sys/sys \
_types.h limits.h cdefs.h _null.h types.h _pthreadtypes.h \
syslimits.h select.h _sigset.h _timeval.h timespec.h \
_timespec.h stat.h signal.h unistd.h time.h param.h stdint.h \
event.h eventhandler.h disk.h errno.h poll.h queue.h mman.h \
stddef.h sysctl.h uio.h _iovec.h ktrace.h ioctl.h ttycom.h \
ioccom.h filio.h sockio.h wait.h file.h fcntl.h resource.h \
disklabel.h link_elf.h endian.h mount.h ucred.h dirent.h \
cpuset.h socket.h un.h ttydefaults.h imgact_aout.h elf32.h \
elf64.h elf_generic.h elf_common.h nlist_aout.h ipc.h sem.h \
exec.h _lock.h _mutex.h statvfs.h ucontext.h syslog.h times.h \
utsname.h elf.h mtio.h _stdint.h atomic_common.h _ucontext.h \
_cpuset.h _bitset.h bitset.h _stdarg.h _uio.h auxv.h random.h \
_sockaddr_storage.h termios.h _termios.h _umtx.h kerneldump.h \
conf.h disk_zone.h counter.h time.h \
mkdir $includedir/sys/rpc
cp sys/rpc/types.h $includedir/sys/rpc
cp -r include/xlocale $includedir/
ln -s sys/poll.h $includedir/poll.h
rm -r include # Don't need this anymore
cp -r $genodeHeaders/include/* $includedir/
compileStub $libcSymbols $out/lib/libc.lib.so
compileStub $vfsSymbols $out/lib/vfs.lib.so
compileLd $out/lib/ld.lib.so
}
genericBuild

8
overlay/libc/libc.pc.in Normal file
View File

@ -0,0 +1,8 @@
Name: libc
Description: Genode C runtime library
URL: https://genode.org/
Version: @version@
Requires: genode-libports
Requires.private: vfs
Cflags: -D__FreeBSD__=12 -D__GENODE__ -fno-builtin-sin -fno-builtin-cos -fno-builtin-sinf -fno-builtin-cosf -I@includedir@
Libs: -l:libc.lib.so

1057
overlay/libc/libc.symbols Normal file

File diff suppressed because it is too large Load Diff

18
overlay/libc/linker.ld Normal file
View File

@ -0,0 +1,18 @@
/*
* \brief LDSO specific linkage settings
* \author Sebastian Sumpf <Sebastian.Sumpf@genode-labs.com>
* \date 2011-04-27
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
SECTIONS
{
/* set ldso memory location */
. = 0x30000;
}

20
overlay/libc/log2.patch Normal file
View File

@ -0,0 +1,20 @@
- add 'log2()' and 'log2f()' declarations
- this patch is only needed for FreeBSD libc versions < 9
+++ src/lib/libc/lib/msun/src/math.h
@@ -204,6 +204,7 @@
double ldexp(double, int);
double log(double);
double log10(double);
+double log2(double);
double modf(double, double *); /* fundamentally !__pure2 */
double pow(double, double);
@@ -317,6 +318,7 @@
int ilogbf(float) __pure2;
float ldexpf(float, int);
float log10f(float);
+float log2f(float);
float log1pf(float);
float logf(float);
float modff(float, float *); /* fundamentally !__pure2 */

44
overlay/libc/mktime.patch Normal file
View File

@ -0,0 +1,44 @@
diff --git a/src/lib/libc/contrib/tzcode/stdtime/localtime.c b/src/lib/libc/contrib/tzcode/stdtime/localtime.c
index 3c66924..05c01ae 100644
--- src/lib/libc/contrib/tzcode/stdtime/localtime.c
+++ src/lib/libc/contrib/tzcode/stdtime/localtime.c
@@ -1935,6 +1935,10 @@ time2sub(struct tm *const tmp,
lo *= 2;
hi = -(lo + 1);
}
+
+ lo = TIME_T_MIN;
+ hi = TIME_T_MAX;
+
for ( ; ; ) {
t = lo / 2 + hi / 2;
if (t < lo)
diff --git a/src/lib/libc/contrib/tzcode/stdtime/private.h b/src/lib/libc/contrib/tzcode/stdtime/private.h
index 354a78b..8300ba0 100644
--- src/lib/libc/contrib/tzcode/stdtime/private.h
+++ src/lib/libc/contrib/tzcode/stdtime/private.h
@@ -251,6 +251,24 @@ const char * scheck(const char * string, const char * format);
1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */
+#define TWOS_COMPLEMENT(t) ((t) ~ (t) 0 < 0)
+
+/* Max and min values of the integer type T, of which only the bottom
+ B bits are used, and where the highest-order used bit is considered
+ to be a sign bit if T is signed. */
+#define MAXVAL(t, b) \
+ ((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \
+ - 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
+#define MINVAL(t, b) \
+ ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
+
+/* The extreme time values, assuming no padding. */
+#define TIME_T_MIN_NO_PADDING MINVAL(time_t, TYPE_BIT(time_t))
+#define TIME_T_MAX_NO_PADDING MAXVAL(time_t, TYPE_BIT(time_t))
+
+# define TIME_T_MIN TIME_T_MIN_NO_PADDING
+# define TIME_T_MAX TIME_T_MAX_NO_PADDING
+
/*
** INITIALIZE(x)
*/

View File

@ -0,0 +1,12 @@
--- src/lib/libc/lib/libc/stdio/printfcommon.h.orig 2019-04-16 12:35:21.549592905 +0200
+++ src/lib/libc/lib/libc/stdio/printfcommon.h 2019-04-16 12:35:34.163738398 +0200
@@ -47,9 +47,6 @@
#ifndef NO_FLOATING_POINT
-#define dtoa __dtoa
-#define freedtoa __freedtoa
-
#include <float.h>
#include <math.h>
#include "floatio.h"

32
overlay/libc/rcmd.patch Normal file
View File

@ -0,0 +1,32 @@
--- src/lib/libc/include/unistd.h
+++ src/lib/libc/include/unistd.h
@@ -510,8 +510,6 @@
int getresuid(uid_t *, uid_t *, uid_t *);
char *getusershell(void);
int initgroups(const char *, gid_t);
-int iruserok(unsigned long, int, const char *, const char *);
-int iruserok_sa(const void *, int, int, const char *, const char *);
int issetugid(void);
long lpathconf(const char *, int);
#ifndef _MKDTEMP_DECLARED
@@ -533,20 +531,12 @@
#endif
int nfssvc(int, void *);
int profil(char *, size_t, vm_offset_t, int);
-int rcmd(char **, int, const char *, const char *, const char *, int *);
-int rcmd_af(char **, int, const char *,
- const char *, const char *, int *, int);
-int rcmdsh(char **, int, const char *,
- const char *, const char *, const char *);
char *re_comp(const char *);
int re_exec(const char *);
int reboot(int);
int revoke(const char *);
pid_t rfork(int);
pid_t rfork_thread(int, void *, int (*)(void *), void *);
-int rresvport(int *);
-int rresvport_af(int *, int);
-int ruserok(const char *, int, const char *, const char *);
#if __BSD_VISIBLE
#ifndef _SELECT_DECLARED
#define _SELECT_DECLARED

View File

@ -0,0 +1,125 @@
--- src/lib/libc/lib/libc/resolv/res_init.c.old 2019-05-07 11:26:07.854155106 +0200
+++ src/lib/libc/lib/libc/resolv/res_init.c 2019-05-07 11:26:18.499341340 +0200
@@ -93,18 +93,7 @@
#include <unistd.h>
#include <netdb.h>
-#ifndef HAVE_MD5
-# include "../dst/md5.h"
-#else
-# ifdef SOLARIS2
-# include <sys/md5.h>
-# elif _LIBC
-# include <md5.h>
-# endif
-#endif
-#ifndef _MD5_H_
-# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */
-#endif
+#include <sys/random.h>
#include "un-namespace.h"
@@ -169,6 +158,10 @@
return (__res_vinit(statp, 0));
}
+
+extern char const *libc_resolv_path;
+
+
/*% This function has to be reachable by res_data.c but not publicly. */
int
__res_vinit(res_state statp, int preinit) {
@@ -325,7 +318,7 @@
line[sizeof(name) - 1] == '\t'))
nserv = 0;
- if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
+ if ((fp = fopen(libc_resolv_path, "re")) != NULL) {
struct stat sb;
struct timespec now;
@@ -339,6 +332,45 @@
}
/* read the config file */
+#if 1
+ if (fgets(buf, sizeof(buf), fp) != NULL) {
+ /* read nameservers to query */
+ struct addrinfo hints, *ai;
+ char sbuf[NI_MAXSERV];
+ const size_t minsiz = sizeof(statp->_u._ext.ext->nsaddrs[0]);
+
+ cp = buf;
+ cp[strcspn(cp, "\n")] = '\0';
+
+ if ((*cp != '\0') && (*cp != '\n')) {
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_DGRAM; /*dummy*/
+ hints.ai_flags = AI_NUMERICHOST;
+ sprintf(sbuf, "%u", NAMESERVER_PORT);
+
+ if (getaddrinfo(cp, sbuf, &hints, &ai) == 0 &&
+ ai->ai_addrlen <= minsiz) {
+ if (statp->_u._ext.ext != NULL) {
+ memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
+ ai->ai_addr, ai->ai_addrlen);
+ }
+
+ if (ai->ai_addrlen <=
+ sizeof(statp->nsaddr_list[nserv])) {
+ memcpy(&statp->nsaddr_list[nserv],
+ ai->ai_addr, ai->ai_addrlen);
+ } else {
+ statp->nsaddr_list[nserv].sin_family = 0;
+ }
+
+ freeaddrinfo(ai);
+ nserv++;
+ }
+ }
+ }
+#else
while (fgets(buf, sizeof(buf), fp) != NULL) {
/* skip comments */
if (*buf == ';' || *buf == '#')
@@ -536,6 +568,7 @@
continue;
}
}
+#endif /* 1 */
if (nserv > 0)
statp->nscount = nserv;
#ifdef RESOLVSORT
@@ -777,25 +810,9 @@
u_int
res_nrandomid(res_state statp) {
- struct timeval now;
- u_int16_t u16;
- MD5_CTX ctx;
- u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
-
- gettimeofday(&now, NULL);
- u16 = (u_int16_t) (now.tv_sec ^ now.tv_usec);
- memcpy(rnd + 14, &u16, 2);
-#ifndef HAVE_MD5
- MD5_Init(&ctx);
- MD5_Update(&ctx, rnd, 16);
- MD5_Final(rnd, &ctx);
-#else
- MD5Init(&ctx);
- MD5Update(&ctx, rnd, 16);
- MD5Final(rnd, &ctx);
-#endif
- memcpy(&u16, rnd + 14, 2);
- return ((u_int) u16);
+ u_int val;
+ getrandom(&val, sizeof(val), 0);
+ return val;
}
/*%

View File

@ -0,0 +1,15 @@
--- src/lib/libc/lib/libc/locale/runetype.c.orig 2019-04-18 15:12:08.961502991 +0200
+++ src/lib/libc/lib/libc/locale/runetype.c 2019-04-18 15:13:44.287945177 +0200
@@ -82,10 +82,9 @@
int ___mb_cur_max(void)
{
- return XLOCALE_CTYPE(__get_locale())->__mb_cur_max;
+ return MB_CUR_MAX;
}
int ___mb_cur_max_l(locale_t locale)
{
- FIX_LOCALE(locale);
- return XLOCALE_CTYPE(locale)->__mb_cur_max;
+ return MB_CUR_MAX;
}

View File

@ -0,0 +1,11 @@
--- src/lib/libc/include/semaphore.h 2019-04-09 14:12:29.619185765 +0200
+++ src/lib/libc/include/semaphore.h.new 2019-04-09 14:31:35.913650094 +0200
@@ -46,7 +46,7 @@
__uint32_t _padding; /* Preserve structure size */
};
-typedef struct _sem sem_t;
+typedef struct sem* sem_t;
#define SEM_FAILED ((sem_t *)0)
#define SEM_VALUE_MAX __INT_MAX

View File

@ -0,0 +1,23 @@
--- src/lib/libc/sys/sys/cdefs.h.orig 2019-04-16 10:50:14.382883576 +0200
+++ src/lib/libc/sys/sys/cdefs.h 2019-04-16 10:50:34.008444965 +0200
@@ -298,20 +298,6 @@
#endif
#endif
-#if !__has_extension(c_thread_local)
-/*
- * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
- * without actually supporting the thread_local keyword. Don't check for
- * the presence of C++11 when defining _Thread_local.
- */
-#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
- __has_extension(cxx_thread_local)
-#define _Thread_local thread_local
-#else
-#define _Thread_local __thread
-#endif
-#endif
-
#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
/*

52
overlay/libc/types.patch Normal file
View File

@ -0,0 +1,52 @@
Use the unified size types provided by the Genode tool chain.
diff --git src/lib/libc/sys/arm/include/_types.h src/lib/libc/sys/arm/include/_types.h
index 3012f97..3ec5a24 100644
--- src/lib/libc/sys/arm/include/_types.h
+++ src/lib/libc/sys/arm/include/_types.h
@@ -85,11 +85,11 @@ typedef __int8_t __int_least8_t;
typedef __int16_t __int_least16_t;
typedef __int32_t __int_least32_t;
typedef __int64_t __int_least64_t;
-typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
+typedef __PTRDIFF_TYPE__ __ptrdiff_t; /* ptr1 - ptr2 */
typedef __int32_t __register_t;
typedef __int32_t __segsz_t; /* segment size (in pages) */
-typedef __uint32_t __size_t; /* sizeof() */
-typedef __int32_t __ssize_t; /* byte count or error */
+typedef __SIZE_TYPE__ __size_t; /* sizeof() */
+typedef __PTRDIFF_TYPE__ __ssize_t; /* byte count or error */
typedef __int64_t __time_t; /* time()... */
typedef __uint32_t __uintfptr_t;
typedef __uint64_t __uintmax_t;
diff --git src/lib/libc/sys/x86/include/_types.h src/lib/libc/sys/x86/include/_types.h
index 07893c6..abd2ea4 100644
--- src/lib/libc/sys/x86/include/_types.h
+++ src/lib/libc/sys/x86/include/_types.h
@@ -100,20 +100,20 @@ typedef __int16_t __int_least16_t;
typedef __int32_t __int_least32_t;
typedef __int64_t __int_least64_t;
#ifdef __LP64__
-typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */
+typedef __PTRDIFF_TYPE__ __ptrdiff_t; /* ptr1 - ptr2 */
typedef __int64_t __register_t;
typedef __int64_t __segsz_t; /* segment size (in pages) */
-typedef __uint64_t __size_t; /* sizeof() */
-typedef __int64_t __ssize_t; /* byte count or error */
+typedef __SIZE_TYPE__ __size_t; /* sizeof() */
+typedef __PTRDIFF_TYPE__ __ssize_t; /* byte count or error */
typedef __int64_t __time_t; /* time()... */
typedef __uint64_t __uintfptr_t;
typedef __uint64_t __uintptr_t;
#else
-typedef __int32_t __ptrdiff_t;
+typedef __PTRDIFF_TYPE__ __ptrdiff_t;
typedef __int32_t __register_t;
typedef __int32_t __segsz_t;
-typedef __uint32_t __size_t;
-typedef __int32_t __ssize_t;
+typedef __SIZE_TYPE__ __size_t;
+typedef __PTRDIFF_TYPE__ __ssize_t;
typedef __int32_t __time_t;
typedef __uint32_t __uintfptr_t;
typedef __uint32_t __uintptr_t;

4
overlay/libc/vfs.pc.in Normal file
View File

@ -0,0 +1,4 @@
Name: VFS
Description: Genode Virtual File-System library
Version: @version@
Libs: -l:vfs.lib.so

5
overlay/libc/vfs.symbols Normal file
View File

@ -0,0 +1,5 @@
_ZN3Vfs26Global_file_system_factory6createERNS_3EnvEN6Genode8Xml_nodeE T
_ZN3Vfs26Global_file_system_factory6extendEPKcRNS_19File_system_factoryE T
_ZN3Vfs26Global_file_system_factoryC1ERN6Genode9AllocatorE T
_ZN3Vfs26Global_file_system_factoryC2ERN6Genode9AllocatorE T
_ZTVN3Vfs26Global_file_system_factoryE D 40

View File

@ -0,0 +1,31 @@
+++ src/lib/libc/lib/libc/stdio/vfwprintf.c
@@ -838,10 +838,10 @@
sign = '-';
if (expt == INT_MAX) { /* inf or nan */
if (*cp == 'N') {
- cp = (ch >= 'a') ? L"nan" : L"NAN";
+ cp = (wchar_t *)((ch >= 'a') ? L"nan" : L"NAN");
sign = '\0';
} else
- cp = (ch >= 'a') ? L"inf" : L"INF";
+ cp = (wchar_t *)((ch >= 'a') ? L"inf" : L"INF");
size = 3;
flags &= ~ZEROPAD;
break;
@@ -953,14 +953,14 @@
case 's':
if (flags & LONGINT) {
if ((cp = GETARG(wchar_t *)) == NULL)
- cp = L"(null)";
+ cp = (wchar_t *)(L"(null)");
} else {
char *mbp;
if (convbuf != NULL)
free(convbuf);
if ((mbp = GETARG(char *)) == NULL)
- cp = L"(null)";
+ cp = (wchar_t *)(L"(null)");
else {
convbuf = __mbsconv(mbp, prec);
if (convbuf == NULL) {

View File

@ -0,0 +1,35 @@
--- src/lib/libc/lib/libc/locale/setrunelocale.c
+++ src/lib/libc/lib/libc/locale/setrunelocale.c
@@ -60,7 +60,7 @@ extern _RuneLocale const *_CurrentRuneLocale;
/*
* A cached version of the runes for this thread. Used by ctype.h
*/
-_Thread_local const _RuneLocale *_ThreadRuneLocale;
+const _RuneLocale *_ThreadRuneLocale;
#endif
extern int __mb_sb_limit;
--- src/lib/libc/lib/libc/locale/xlocale.c
+++ src/lib/libc/lib/libc/locale/xlocale.c
@@ -59,7 +59,7 @@ extern struct xlocale_component __xlocale_C_ctype;
/*
* The locale for this thread.
*/
-_Thread_local locale_t __thread_locale;
+locale_t __thread_locale;
#endif
/*
* Flag indicating that one or more per-thread locales exist.
--- src/lib/libc/lib/libc/locale/xlocale_private.h
+++ src/lib/libc/lib/libc/locale/xlocale_private.h
@@ -213,7 +213,7 @@ extern int __has_thread_locale;
* The per-thread locale. Avoids the need to use pthread lookup functions when
* getting the per-thread locale.
*/
-extern _Thread_local locale_t __thread_locale;
+extern locale_t __thread_locale;
/**
* Returns the current locale for this thread, or the global locale if none is

View File

@ -0,0 +1,59 @@
--- src/lib/libc/lib/libc/locale/xlocale_private.h.orig 2019-04-18 14:31:34.331373088 +0200
+++ src/lib/libc/lib/libc/locale/xlocale_private.h 2019-04-18 14:31:57.418620988 +0200
@@ -166,24 +166,16 @@
__attribute__((unused)) static void*
xlocale_retain(void *val)
{
- struct xlocale_refcounted *obj = val;
- atomic_add_long(&(obj->retain_count), 1);
return (val);
}
+
/**
* Decrements the reference count of a reference-counted structure, freeing it
* if this is the last reference, calling its destructor if it has one.
*/
__attribute__((unused)) static void
xlocale_release(void *val)
-{
- struct xlocale_refcounted *obj = val;
- long count;
-
- count = atomic_fetchadd_long(&(obj->retain_count), -1) - 1;
- if (count < 0 && obj->destructor != NULL)
- obj->destructor(obj);
-}
+{ }
/**
* Load functions. Each takes the name of a locale and a pointer to the data
@@ -223,27 +215,15 @@
*/
static inline locale_t __get_locale(void)
{
-
- if (!__has_thread_locale) {
- return (&__xlocale_global_locale);
- }
- return (__thread_locale ? __thread_locale : &__xlocale_global_locale);
+ return (&__xlocale_global_locale);
}
#else
locale_t __get_locale(void);
#endif
-/**
- * Two magic values are allowed for locale_t objects. NULL and -1. This
- * function maps those to the real locales that they represent.
- */
static inline locale_t get_real_locale(locale_t locale)
{
- switch ((intptr_t)locale) {
- case 0: return (&__xlocale_C_locale);
- case -1: return (&__xlocale_global_locale);
- default: return (locale);
- }
+ return &__xlocale_global_locale;
}
/**

View File

@ -0,0 +1,12 @@
--- src/lib/libc/lib/libc/stdio/xprintf_float.c.orig 2019-04-16 12:34:20.167688219 +0200
+++ src/lib/libc/lib/libc/stdio/xprintf_float.c 2019-04-16 12:34:01.986830677 +0200
@@ -42,9 +42,6 @@
#include <locale.h>
#include <limits.h>
-#define dtoa __dtoa
-#define freedtoa __freedtoa
-
#include <float.h>
#include <math.h>
#include "gdtoa.h"

View File

@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ runCommand, stdenv, llvm, lld, version }:
let
prefix =
if stdenv.hostPlatform != stdenv.targetPlatform
then "${stdenv.targetPlatform.config}-"
else "";
in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } ''
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/${prefix}$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -s $prog $out/bin/${prefix}$(echo $(basename $prog) | sed -e "s|llvm-||")
ln -sf $prog $out/bin/${prefix}$(basename $prog)
done
rm -f $out/bin/${prefix}cat
ln -s ${lld}/bin/lld $out/bin/${prefix}ld
''

View File

@ -0,0 +1,41 @@
From 61c9b97d7b81cc2c013b423bf1763a92b14fcae3 Mon Sep 17 00:00:00 2001
From: Jan Korous <jkorous@apple.com>
Date: Tue, 26 Mar 2019 03:48:25 +0000
Subject: [PATCH] [clangd][xpc][cmake] Respect explicit value of
CLANGD_BUILD_XPC
We shouldn't prevent user from disabling XPC framework build on Darwin.
However, by keeping it on by default our CI systems also test
it by default on macOS.
Based on user request:
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061778.html
Differential Revision: https://reviews.llvm.org/D59808
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@356974 91177308-0d34-0410-b5e6-96231b3b80d8
---
CMakeLists.txt | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66ebeaeeaa..514b17fb3c 100644
--- a/tools/extra/CMakeLists.txt
+++ b/tools/extra/CMakeLists.txt
@@ -1,6 +1,13 @@
-option(CLANGD_BUILD_XPC "Build XPC Support For Clangd." OFF)
-if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- set(CLANGD_BUILD_XPC ON CACHE BOOL "" FORCE)
+if (NOT DEFINED CLANGD_BUILD_XPC)
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set(CLANGD_BUILD_XPC_DEFAULT ON)
+ else ()
+ set(CLANGD_BUILD_XPC_DEFAULT OFF)
+ endif ()
+
+ set(CLANGD_BUILD_XPC ${CLANGD_BUILD_XPC_DEFAULT} CACHE BOOL "Build XPC Support For Clangd." FORCE)
+
+ unset(CLANGD_BUILD_XPC_DEFAULT)
endif ()
add_subdirectory(clang-apply-replacements)

View File

@ -0,0 +1,53 @@
Index: lib/Driver/ToolChains/BareMetal.cpp
===================================================================
--- a/lib/Driver/ToolChains/BareMetal.cpp
+++ b/lib/Driver/ToolChains/BareMetal.cpp
@@ -157,7 +157,7 @@
void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
ArgStringList &CmdArgs) const {
CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
- getTriple().getArchName() + ".a"));
+ getTriple().getArchName()));
}
void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Index: test/Driver/baremetal.cpp
===================================================================
--- a/test/Driver/baremetal.cpp
+++ b/test/Driver/baremetal.cpp
@@ -13,7 +13,7 @@
// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
-// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -35,7 +35,7 @@
// CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -48,7 +48,7 @@
// CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -61,7 +61,7 @@
// CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-LIBSTDCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
// CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
-// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \

View File

@ -0,0 +1,131 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv, fetch, cmake, libxml2, llvm, version, clang-tools-extra_src, python
, fixDarwinDylibNames
, enableManpages ? false
, enablePolly ? false # TODO: get this info from llvm (passthru?)
}:
let
self = stdenv.mkDerivation ({
name = "clang-${version}";
src = fetch "cfe" "0ihnbdl058gvl2wdy45p5am55bq8ifx8m9mhcsgj9ax8yxlzvvvh";
unpackPhase = ''
unpackFile $src
mv cfe-${version}* clang
sourceRoot=$PWD/clang
unpackFile ${clang-tools-extra_src}
mv clang-tools-extra-* $sourceRoot/tools/extra
'';
nativeBuildInputs = [ cmake python ]
++ stdenv.lib.optional enableManpages python.pkgs.sphinx;
buildInputs = [ libxml2 llvm ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
cmakeFlags = [
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DCLANGD_BUILD_XPC=OFF"
] ++ stdenv.lib.optionals enableManpages [
"-DCLANG_INCLUDE_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ stdenv.lib.optionals enablePolly [
"-DWITH_POLLY=ON"
"-DLINK_POLLY_INTO_TOOLS=ON"
];
patches = [
./purity.patch
./clang-xpc.patch
# Backport for -static-pie, which the latter touches, and which is nice in
# its own right.
./static-pie.patch
# Backport for the `--unwindlib=[libgcc|compiler-rt]` flag, which is
# needed for our bootstrapping to not interfere with C.
./unwindlib.patch
# https://reviews.llvm.org/D51899
./compiler-rt-baremetal.patch
./genode.patch
];
postPatch = ''
sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' \
-e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' \
lib/Driver/ToolChains/*.cpp
# Patch for standalone doc building
sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
sed -i -e 's/lgcc_s/lgcc_eh/' lib/Driver/ToolChains/*.cpp
'' + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace tools/extra/clangd/CMakeLists.txt \
--replace "NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB" FALSE
'';
outputs = [ "out" "lib" "python" ];
# Clang expects to find LLVMgold in its own prefix
postInstall = ''
if [ -e ${llvm}/lib/LLVMgold.so ]; then
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
fi
ln -sv $out/bin/clang $out/bin/cpp
# Move libclang to 'lib' output
moveToOutput "lib/libclang.*" "$lib"
substituteInPlace $out/lib/cmake/clang/ClangTargets-release.cmake \
--replace "\''${_IMPORT_PREFIX}/lib/libclang." "$lib/lib/libclang."
mkdir -p $python/bin $python/share/clang/
mv $out/bin/{git-clang-format,scan-view} $python/bin
if [ -e $out/bin/set-xcode-analyzer ]; then
mv $out/bin/set-xcode-analyzer $python/bin
fi
mv $out/share/clang/*.py $python/share/clang
rm $out/bin/c-index-test
'';
enableParallelBuilding = true;
passthru = {
isClang = true;
inherit llvm;
} // stdenv.lib.optionalAttrs (stdenv.targetPlatform.isLinux || (stdenv.cc.isGNU && stdenv.cc.cc ? gcc)) {
gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc;
};
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.ncsa;
platforms = stdenv.lib.platforms.all;
};
} // stdenv.lib.optionalAttrs enableManpages {
name = "clang-manpages-${version}";
buildPhase = ''
make docs-clang-man
'';
installPhase = ''
mkdir -p $out/share/man/man1
# Manually install clang manpage
cp docs/man/*.1 $out/share/man/man1/
'';
outputs = [ "out" ];
doCheck = false;
meta.description = "man page for Clang ${version}";
});
in self

View File

@ -0,0 +1,300 @@
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 3c139d72479..89d6df3f5b4 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -147,6 +147,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new FreeBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<AArch64leTargetInfo>(Triple, Opts);
+ case llvm::Triple::Genode:
+ return new GenodeTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::NetBSD:
@@ -171,6 +173,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new FreeBSDTargetInfo<AArch64beTargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<AArch64beTargetInfo>(Triple, Opts);
+ case llvm::Triple::Genode:
+ return new GenodeTargetInfo<AArch64beTargetInfo>(Triple, Opts);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64beTargetInfo>(Triple, Opts);
case llvm::Triple::NetBSD:
@@ -528,6 +532,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<X86_64TargetInfo>(Triple, Opts);
+ case llvm::Triple::Genode:
+ return new GenodeTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::KFreeBSD:
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Solaris:
diff --git a/lib/Basic/Targets/OSTargets.h b/lib/Basic/Targets/OSTargets.h
index 09867d82c38..f67151a13e8 100644
--- a/lib/Basic/Targets/OSTargets.h
+++ b/lib/Basic/Targets/OSTargets.h
@@ -760,6 +760,26 @@ public:
}
};
+// Genode Target
+template <typename Target>
+class LLVM_LIBRARY_VISIBILITY GenodeTargetInfo : public OSTargetInfo<Target> {
+protected:
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+ MacroBuilder &Builder) const override {
+ Builder.defineMacro("__GENODE__");
+ Builder.defineMacro("__ELF__");
+ // Required by the libc++ locale support.
+ if (Opts.CPlusPlus)
+ Builder.defineMacro("_GNU_SOURCE");
+ }
+
+public:
+ GenodeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ : OSTargetInfo<Target>(Triple, Opts) {
+ this->MCountName = "__mcount";
+ }
+};
+
// WebAssembly target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
index 4793a1f90b2..4691b898eb2 100644
--- a/lib/Driver/CMakeLists.txt
+++ b/lib/Driver/CMakeLists.txt
@@ -44,6 +44,7 @@ add_clang_library(clangDriver
ToolChains/DragonFly.cpp
ToolChains/FreeBSD.cpp
ToolChains/Fuchsia.cpp
+ ToolChains/Genode.cpp
ToolChains/Gnu.cpp
ToolChains/Haiku.cpp
ToolChains/HIP.cpp
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index a784e218f13..881b78abc4d 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -22,6 +22,7 @@
#include "ToolChains/DragonFly.h"
#include "ToolChains/FreeBSD.h"
#include "ToolChains/Fuchsia.h"
+#include "ToolChains/Genode.h"
#include "ToolChains/Gnu.h"
#include "ToolChains/HIP.h"
#include "ToolChains/Haiku.h"
@@ -4570,6 +4571,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::Solaris:
TC = llvm::make_unique<toolchains::Solaris>(*this, Target, Args);
break;
+ case llvm::Triple::Genode:
+ TC = llvm::make_unique<toolchains::Genode>(*this, Target, Args);
+ break;
case llvm::Triple::AMDHSA:
TC = llvm::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
break;
diff --git a/lib/Driver/SanitizerArgs.cpp b/lib/Driver/SanitizerArgs.cpp
index 1a46073aaa3..72b6f7389a3 100644
--- a/lib/Driver/SanitizerArgs.cpp
+++ b/lib/Driver/SanitizerArgs.cpp
@@ -693,7 +693,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
ImplicitCfiRuntime = TC.getTriple().isAndroid();
if (AllAddedKinds & Address) {
- NeedPIE |= TC.getTriple().isOSFuchsia();
+ NeedPIE |= TC.getTriple().isOSFuchsia() | TC.getTriple().isOSGenode();
if (Arg *A =
Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
StringRef S = A->getValue();
diff --git a/lib/Driver/ToolChains/Genode.cpp b/lib/Driver/ToolChains/Genode.cpp
new file mode 100644
index 00000000000..cbb1b9e30c4
--- /dev/null
+++ b/lib/Driver/ToolChains/Genode.cpp
@@ -0,0 +1,84 @@
+//===--- Genode.cpp - CloudABI ToolChain Implementations --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "Genode.h"
+#include "InputInfo.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang::driver;
+using namespace clang::driver::tools;
+using namespace clang::driver::toolchains;
+using namespace clang;
+using namespace llvm::opt;
+
+void genode::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const llvm::opt::ArgList &Args,
+ const char *LinkingOutput) const {
+ const ToolChain &ToolChain = getToolChain();
+ const Driver &D = ToolChain.getDriver();
+ ArgStringList CmdArgs;
+
+ if (Output.isFilename()) {
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back(Output.getFilename());
+ } else {
+ assert(Output.isNothing() && "Invalid output.");
+ }
+
+ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
+
+ const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
+}
+
+Genode::Genode(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args)
+ : Generic_ELF(D, Triple, Args) {
+ SmallString<128> P(getDriver().Dir);
+ llvm::sys::path::append(P, "..", getTriple().str(), "lib");
+ getFilePaths().push_back(P.str());
+}
+
+void Genode::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ SmallString<128> P(getDriver().Dir);
+ llvm::sys::path::append(P, "..", getTriple().str(), "include/c++/v1");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+}
+
+bool Genode::isPIEDefault() const {
+ switch (getTriple().getArch()) {
+ case llvm::Triple::aarch64:
+ case llvm::Triple::x86_64:
+ return true;
+ default:
+ return false;
+ }
+}
+
+SanitizerMask Genode::getSupportedSanitizers() const {
+ return Generic_ELF::getSupportedSanitizers();
+}
+
+SanitizerMask Genode::getDefaultSanitizers() const {
+ return Generic_ELF::getDefaultSanitizers();
+}
+
+Tool *Genode::buildLinker() const {
+ return new tools::genode::Linker(*this);
+}
diff --git a/lib/Driver/ToolChains/Genode.h b/lib/Driver/ToolChains/Genode.h
new file mode 100644
index 00000000000..971efb04ef9
--- /dev/null
+++ b/lib/Driver/ToolChains/Genode.h
@@ -0,0 +1,69 @@
+//===----- Genode.h - CloudABI ToolChain Implementations --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
+
+#include "Gnu.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+
+//// genode -- Directly call GNU Binutils linker
+namespace genode {
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+ Linker(const ToolChain &TC) : GnuTool("genode::Linker", "linker", TC) {}
+
+ bool hasIntegratedCPP() const override { return false; }
+ bool isLinkJob() const override { return true; }
+
+ void ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output, const InputInfoList &Inputss,
+ const llvm::opt::ArgList &Args,
+ const char *LinkingOutput) const override;
+};
+} // end namespace genode
+} // end namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY Genode : public Generic_ELF {
+public:
+ Genode(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args);
+ bool HasNativeLLVMSupport() const override { return true; }
+
+ bool IsMathErrnoDefault() const override { return true; }
+
+ CXXStdlibType
+ GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
+ return ToolChain::CST_Libcxx;
+ }
+ void addLibCxxIncludePaths(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+
+ bool isPIEDefault() const override;
+ SanitizerMask getSupportedSanitizers() const override;
+ SanitizerMask getDefaultSanitizers() const override;
+
+protected:
+ Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 67842b5dca2..26a2c65fec2 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -221,6 +221,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::PS4:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Fuchsia:
+ case llvm::Triple::Genode:
break;
case llvm::Triple::Win32:
if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -329,6 +330,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::NaCl:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Fuchsia:
+ case llvm::Triple::Genode:
break;
case llvm::Triple::PS4: {
// <isysroot> gets prepended later in AddPath().
diff --git a/test/Driver/genode.c b/test/Driver/genode.c
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/test/Driver/genode.cpp b/test/Driver/genode.cpp
new file mode 100644
index 00000000000..e69de29bb2d

View File

@ -0,0 +1,30 @@
From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001
From: Will Dietz <w@wdtz.org>
Date: Thu, 18 May 2017 11:56:12 -0500
Subject: [PATCH] "purity" patch for 5.0
---
lib/Driver/ToolChains/Gnu.cpp | 7 -------
1 file changed, 7 deletions(-)
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
index fe3c0191bb..c6a482bece 100644
--- a/lib/Driver/ToolChains/Gnu.cpp
+++ b/lib/Driver/ToolChains/Gnu.cpp
@@ -494,13 +494,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_static)) {
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
-
- if (!Args.hasArg(options::OPT_shared)) {
- const std::string Loader =
- D.DyldPrefix + ToolChain.getDynamicLinker(Args);
- CmdArgs.push_back("-dynamic-linker");
- CmdArgs.push_back(Args.MakeArgString(Loader));
- }
}
CmdArgs.push_back("-o");
--
2.11.0

View File

@ -0,0 +1,157 @@
commit 7a9842bc92921e79b84630045276861be90b2d47
Author: Siva Chandra <sivachandra@google.com>
Date: Wed Feb 20 19:07:04 2019 +0000
[Clang Driver] Add support for "-static-pie" argument to the Clang driver.
Summary: This change mimics GCC's support for the "-static-pie" argument.
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58307
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354502 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 7d6cd7825e6883f8650e32b07f3750824c2cef62)
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index d02d9744d7..75a21e66c7 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -2502,6 +2502,7 @@ def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
def p : Flag<["-"], "p">;
def pie : Flag<["-"], "pie">;
+def static_pie : Flag<["-"], "static-pie">;
def read__only__relocs : Separate<["-"], "read_only_relocs">;
def remap : Flag<["-"], "remap">;
def rewrite_objc : Flag<["-"], "rewrite-objc">, Flags<[DriverOption,CC1Option]>,
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
index d7e316befa..85ffc1618d 100644
--- a/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1138,19 +1138,22 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
bool isCygMing = Triple.isOSCygMing();
bool IsIAMCU = Triple.isOSIAMCU();
bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
- Args.hasArg(options::OPT_static);
+ Args.hasArg(options::OPT_static) ||
+ Args.hasArg(options::OPT_static_pie);
bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc);
bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc;
// Gcc adds libgcc arguments in various ways:
//
- // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
- // g++ <none>: -lgcc_s -lgcc
- // gcc shared: -lgcc_s -lgcc
- // g++ shared: -lgcc_s -lgcc
- // gcc static: -lgcc -lgcc_eh
- // g++ static: -lgcc -lgcc_eh
+ // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
+ // g++ <none>: -lgcc_s -lgcc
+ // gcc shared: -lgcc_s -lgcc
+ // g++ shared: -lgcc_s -lgcc
+ // gcc static: -lgcc -lgcc_eh
+ // g++ static: -lgcc -lgcc_eh
+ // gcc static-pie: -lgcc -lgcc_eh
+ // g++ static-pie: -lgcc -lgcc_eh
//
// Also, certain targets need additional adjustments.
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
index 69dba8fec8..0faa0bb473 100644
--- a/lib/Driver/ToolChains/Gnu.cpp
+++ b/lib/Driver/ToolChains/Gnu.cpp
@@ -334,6 +334,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const bool isAndroid = ToolChain.getTriple().isAndroid();
const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
const bool IsPIE = getPIE(Args, ToolChain);
+ const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
const bool HasCRTBeginEndFiles =
ToolChain.getTriple().hasEnvironment() ||
(ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
@@ -354,6 +355,12 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (IsPIE)
CmdArgs.push_back("-pie");
+ if (IsStaticPIE) {
+ CmdArgs.push_back("-static");
+ CmdArgs.push_back("-pie");
+ CmdArgs.push_back("--no-dynamic-linker");
+ }
+
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
@@ -415,6 +422,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
crt1 = "gcrt1.o";
else if (IsPIE)
crt1 = "Scrt1.o";
+ else if (IsStaticPIE)
+ crt1 = "rcrt1.o";
else
crt1 = "crt1.o";
}
@@ -432,7 +441,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
else if (Args.hasArg(options::OPT_shared))
crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
- else if (IsPIE)
+ else if (IsPIE || IsStaticPIE)
crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
else
crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
@@ -483,7 +492,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_nostdlib)) {
if (!Args.hasArg(options::OPT_nodefaultlibs)) {
- if (Args.hasArg(options::OPT_static))
+ if (Args.hasArg(options::OPT_static) || IsStaticPIE)
CmdArgs.push_back("--start-group");
if (NeedsSanitizerDeps)
@@ -518,7 +527,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (IsIAMCU)
CmdArgs.push_back("-lgloss");
- if (Args.hasArg(options::OPT_static))
+ if (Args.hasArg(options::OPT_static) || IsStaticPIE)
CmdArgs.push_back("--end-group");
else
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
@@ -535,7 +544,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const char *crtend;
if (Args.hasArg(options::OPT_shared))
crtend = isAndroid ? "crtend_so.o" : "crtendS.o";
- else if (IsPIE)
+ else if (IsPIE || IsStaticPIE)
crtend = isAndroid ? "crtend_android.o" : "crtendS.o";
else
crtend = isAndroid ? "crtend_android.o" : "crtend.o";
diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
index 3ab81be490..800f782523 100644
--- a/test/Driver/linux-ld.c
+++ b/test/Driver/linux-ld.c
@@ -176,6 +176,19 @@
// CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
//
+// RUN: %clang -static-pie -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE %s
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-LD-STATIC-PIE: "-static"
+// CHECK-CLANG-LD-STATIC-PIE: "-pie"
+// CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
+// CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
+//
// RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=x86_64-unknown-linux -rtlib=platform \
// RUN: --gcc-toolchain="" \

View File

@ -0,0 +1,372 @@
commit cd5603a4767277a29d3e67a9c3f2a5d2129cd973
Author: Sterling Augustine <saugustine@google.com>
Date: Tue Mar 19 20:01:59 2019 +0000
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib= [take 2]
"clang++ hello.cc --rtlib=compiler-rt"
now can works without specifying additional unwind or exception
handling libraries.
This reworked version of the feature no longer modifies today's default
unwind library for compiler-rt: which is nothing. Rather, a user
can specify -DCLANG_DEFAULT_UNWINDLIB=libunwind when configuring
the compiler.
This should address the issues from the previous version.
Update tests for new --unwindlib semantics.
Differential Revision: https://reviews.llvm.org/D59109
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356508 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 344aa82a52f2fae527f58284567ae305a314f7a8)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2016a45ca..edeb2b66a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -261,6 +261,24 @@ if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
"Default runtime library to use (\"libgcc\" or \"compiler-rt\", empty for platform default)" FORCE)
endif()
+set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
+ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)")
+if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
+ if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
+ set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
+ elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind")
+ set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
+ endif()
+endif()
+
+if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "none" OR
+ CLANG_DEFAULT_UNWINDLIB STREQUAL "libgcc" OR
+ CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
+ message(WARNING "Resetting default unwindlib to use platform default")
+ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
+ "Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE)
+endif()
+
set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
"Default objcopy executable to use.")
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td
index 5475e28ed7..15971210e4 100644
--- a/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/include/clang/Basic/DiagnosticDriverKinds.td
@@ -52,6 +52,10 @@ def err_drv_invalid_rtlib_name : Error<
"invalid runtime library name in argument '%0'">;
def err_drv_unsupported_rtlib_for_platform : Error<
"unsupported runtime library '%0' for platform '%1'">;
+def err_drv_invalid_unwindlib_name : Error<
+ "invalid unwind library name in argument '%0'">;
+def err_drv_incompatible_unwindlib : Error<
+ "--rtlib=libgcc requires --unwindlib=libgcc">;
def err_drv_invalid_stdlib_name : Error<
"invalid library name in argument '%0'">;
def err_drv_invalid_output_with_multiple_archs : Error<
diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake
index 1d624450b9..2d4cb747e8 100644
--- a/include/clang/Config/config.h.cmake
+++ b/include/clang/Config/config.h.cmake
@@ -23,6 +23,9 @@
/* Default runtime library to use. */
#define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
+/* Default unwind library to use. */
+#define CLANG_DEFAULT_UNWINDLIB "${CLANG_DEFAULT_UNWINDLIB}"
+
/* Default objcopy to use */
#define CLANG_DEFAULT_OBJCOPY "${CLANG_DEFAULT_OBJCOPY}"
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 75a21e66c7..4da0e54965 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -2570,6 +2570,8 @@ def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>,
}]>;
def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
+def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
+ HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">;
def sub__library : JoinedOrSeparate<["-"], "sub_library">;
def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
def system_header_prefix : Joined<["--"], "system-header-prefix=">,
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
index d5f75b8271..4bedf760eb 100644
--- a/include/clang/Driver/ToolChain.h
+++ b/include/clang/Driver/ToolChain.h
@@ -100,6 +100,12 @@ public:
RLT_Libgcc
};
+ enum UnwindLibType {
+ UNW_None,
+ UNW_CompilerRT,
+ UNW_Libgcc
+ };
+
enum RTTIMode {
RM_Enabled,
RM_Disabled,
@@ -368,6 +374,10 @@ public:
return ToolChain::CST_Libstdcxx;
}
+ virtual UnwindLibType GetDefaultUnwindLibType() const {
+ return ToolChain::UNW_None;
+ }
+
virtual std::string getCompilerRTPath() const;
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
@@ -512,6 +522,10 @@ public:
// given compilation arguments.
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
+ // GetUnwindLibType - Determine the unwind library type to use with the
+ // given compilation arguments.
+ virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
+
/// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
/// the include paths to use for the given C++ standard library type.
virtual void
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 88a627eab6..d82423f4a8 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -680,6 +680,33 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
return GetDefaultRuntimeLibType();
}
+ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
+ const ArgList &Args) const {
+ const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;
+
+ if (LibName == "none")
+ return ToolChain::UNW_None;
+ else if (LibName == "platform" || LibName == "") {
+ ToolChain::RuntimeLibType RtLibType = GetRuntimeLibType(Args);
+ if (RtLibType == ToolChain::RLT_CompilerRT)
+ return ToolChain::UNW_None;
+ else if (RtLibType == ToolChain::RLT_Libgcc)
+ return ToolChain::UNW_Libgcc;
+ } else if (LibName == "libunwind") {
+ if (GetRuntimeLibType(Args) == RLT_Libgcc)
+ getDriver().Diag(diag::err_drv_incompatible_unwindlib);
+ return ToolChain::UNW_CompilerRT;
+ } else if (LibName == "libgcc")
+ return ToolChain::UNW_Libgcc;
+
+ if (A)
+ getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
+ << A->getAsString(Args);
+
+ return GetDefaultUnwindLibType();
+}
+
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
index 85ffc1618d..9fd29726a4 100644
--- a/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1132,47 +1132,80 @@ bool tools::isObjCAutoRefCount(const ArgList &Args) {
return Args.hasFlag(options::OPT_fobjc_arc, options::OPT_fno_objc_arc, false);
}
-static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
- ArgStringList &CmdArgs, const ArgList &Args) {
- bool isAndroid = Triple.isAndroid();
- bool isCygMing = Triple.isOSCygMing();
- bool IsIAMCU = Triple.isOSIAMCU();
- bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
- Args.hasArg(options::OPT_static) ||
- Args.hasArg(options::OPT_static_pie);
-
- bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc);
- bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc;
-
- // Gcc adds libgcc arguments in various ways:
- //
- // gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
- // g++ <none>: -lgcc_s -lgcc
- // gcc shared: -lgcc_s -lgcc
- // g++ shared: -lgcc_s -lgcc
- // gcc static: -lgcc -lgcc_eh
- // g++ static: -lgcc -lgcc_eh
- // gcc static-pie: -lgcc -lgcc_eh
- // g++ static-pie: -lgcc -lgcc_eh
- //
- // Also, certain targets need additional adjustments.
+enum class LibGccType { UnspecifiedLibGcc, StaticLibGcc, SharedLibGcc };
+
+static LibGccType getLibGccType(const ArgList &Args) {
+ bool Static = Args.hasArg(options::OPT_static_libgcc) ||
+ Args.hasArg(options::OPT_static) ||
+ Args.hasArg(options::OPT_static_pie);
+
+ bool Shared = Args.hasArg(options::OPT_shared_libgcc);
+ if (Shared)
+ return LibGccType::SharedLibGcc;
+ if (Static)
+ return LibGccType::StaticLibGcc;
+ return LibGccType::UnspecifiedLibGcc;
+}
- bool LibGccFirst = (D.CCCIsCC() && UnspecifiedLibgcc) || StaticLibgcc;
- if (LibGccFirst)
- CmdArgs.push_back("-lgcc");
+// Gcc adds libgcc arguments in various ways:
+//
+// gcc <none>: -lgcc --as-needed -lgcc_s --no-as-needed
+// g++ <none>: -lgcc_s -lgcc
+// gcc shared: -lgcc_s -lgcc
+// g++ shared: -lgcc_s -lgcc
+// gcc static: -lgcc -lgcc_eh
+// g++ static: -lgcc -lgcc_eh
+// gcc static-pie: -lgcc -lgcc_eh
+// g++ static-pie: -lgcc -lgcc_eh
+//
+// Also, certain targets need additional adjustments.
+
+static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
+ ArgStringList &CmdArgs, const ArgList &Args) {
+ ToolChain::UnwindLibType UNW = TC.GetUnwindLibType(Args);
+ // Targets that don't use unwind libraries.
+ if (TC.getTriple().isAndroid() || TC.getTriple().isOSIAMCU() ||
+ TC.getTriple().isOSBinFormatWasm() ||
+ UNW == ToolChain::UNW_None)
+ return;
- bool AsNeeded = D.CCCIsCC() && UnspecifiedLibgcc && !isAndroid && !isCygMing;
+ LibGccType LGT = getLibGccType(Args);
+ bool AsNeeded = D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc &&
+ !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing();
if (AsNeeded)
CmdArgs.push_back("--as-needed");
- if ((UnspecifiedLibgcc || SharedLibgcc) && !isAndroid)
- CmdArgs.push_back("-lgcc_s");
-
- else if (StaticLibgcc && !isAndroid && !IsIAMCU)
- CmdArgs.push_back("-lgcc_eh");
+ switch (UNW) {
+ case ToolChain::UNW_None:
+ return;
+ case ToolChain::UNW_Libgcc: {
+ LibGccType LGT = getLibGccType(Args);
+ if (LGT == LibGccType::UnspecifiedLibGcc || LGT == LibGccType::SharedLibGcc)
+ CmdArgs.push_back("-lgcc_s");
+ else if (LGT == LibGccType::StaticLibGcc)
+ CmdArgs.push_back("-lgcc_eh");
+ break;
+ }
+ case ToolChain::UNW_CompilerRT:
+ CmdArgs.push_back("-lunwind");
+ break;
+ }
if (AsNeeded)
CmdArgs.push_back("--no-as-needed");
+}
+
+static void AddLibgcc(const ToolChain &TC, const Driver &D,
+ ArgStringList &CmdArgs, const ArgList &Args) {
+ bool isAndroid = TC.getTriple().isAndroid();
+
+ LibGccType LGT = getLibGccType(Args);
+ bool LibGccFirst = (D.CCCIsCC() && LGT == LibGccType::UnspecifiedLibGcc) ||
+ LGT == LibGccType::StaticLibGcc;
+ if (LibGccFirst)
+ CmdArgs.push_back("-lgcc");
+
+ AddUnwindLibrary(TC, D, CmdArgs, Args);
if (!LibGccFirst)
CmdArgs.push_back("-lgcc");
@@ -1182,7 +1215,7 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
//
// NOTE: This fixes a link error on Android MIPS as well. The non-static
// libgcc for MIPS relies on _Unwind_Find_FDE and dl_iterate_phdr from libdl.
- if (isAndroid && !StaticLibgcc)
+ if (isAndroid && getLibGccType(Args) != LibGccType::StaticLibGcc)
CmdArgs.push_back("-ldl");
}
@@ -1194,6 +1227,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
switch (RLT) {
case ToolChain::RLT_CompilerRT:
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
+ AddUnwindLibrary(TC, D, CmdArgs, Args);
break;
case ToolChain::RLT_Libgcc:
// Make sure libgcc is not used under MSVC environment by default
@@ -1205,7 +1239,7 @@ void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
<< Args.getLastArg(options::OPT_rtlib_EQ)->getValue() << "MSVC";
}
} else
- AddLibgcc(TC.getTriple(), D, CmdArgs, Args);
+ AddLibgcc(TC, D, CmdArgs, Args);
break;
}
}
diff --git a/test/Driver/compiler-rt-unwind.c b/test/Driver/compiler-rt-unwind.c
new file mode 100644
index 0000000000..00024dfa7e
--- /dev/null
+++ b/test/Driver/compiler-rt-unwind.c
@@ -0,0 +1,49 @@
+// General tests that the driver handles combinations of --rtlib=XXX and
+// --unwindlib=XXX properly.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-EMPTY %s
+// RTLIB-EMPTY: "{{.*}}lgcc"
+// RTLIB-EMPTY: "{{.*}}-lgcc_s"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-GCC %s
+// RTLIB-GCC: "{{.*}}lgcc"
+// RTLIB-GCC: "{{.*}}lgcc_s"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT %s
+// RTLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \
+// RUN: --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC %s
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC: "{{.*}}lgcc_s"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=compiler-rt --unwindlib=libgcc \
+// RUN: -static --gcc-toolchain="" \
+// RUN: | FileCheck --check-prefix=RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC %s
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}libclang_rt.builtins-x86_64.a"
+// RTLIB-COMPILER-RT-UNWINDLIB-GCC-STATIC: "{{.*}}lgcc_eh"
+//
+// RUN: not %clang -no-canonical-prefixes %s -o %t.o 2> %t.err \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: --gcc-toolchain="" \
+// RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s
+// RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"

View File

@ -0,0 +1,33 @@
From 3dec5f3475a26aeb4678627795c4b67c6b7b4785 Mon Sep 17 00:00:00 2001
From: Will Dietz <w@wdtz.org>
Date: Tue, 19 Sep 2017 13:13:06 -0500
Subject: [PATCH] remove codesign use on Apple, disable ios sim testing that
needs it
---
cmake/Modules/AddCompilerRT.cmake | 8 ------
test/asan/CMakeLists.txt | 52 ---------------------------------------
test/tsan/CMakeLists.txt | 47 -----------------------------------
3 files changed, 107 deletions(-)
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index bc5fb9ff7..b64eb4246 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -210,14 +210,6 @@ function(add_compiler_rt_runtime name type)
set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
set_target_properties(${libname} PROPERTIES IMPORT_SUFFIX ".lib")
endif()
- if(APPLE)
- # Ad-hoc sign the dylibs
- add_custom_command(TARGET ${libname}
- POST_BUILD
- COMMAND codesign --sign - $<TARGET_FILE:${libname}>
- WORKING_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
- )
- endif()
endif()
install(TARGETS ${libname}
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
2.14.1

View File

@ -0,0 +1,13 @@
diff --git a/lib/builtins/assembly.h b/lib/builtins/assembly.h
index 3f5e59b2544..97d06d6ccd1 100644
--- a/lib/builtins/assembly.h
+++ b/lib/builtins/assembly.h
@@ -45,7 +45,7 @@
#define CONST_SECTION .section .rodata
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
- defined(__linux__)
+ defined(__linux__) || defined(__GENODE__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE

View File

@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
stdenv.mkDerivation {
pname = "compiler-rt";
inherit version;
src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
nativeBuildInputs = [ cmake python llvm ];
buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
cmakeFlags = [
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
"-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
"-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
"-DCMAKE_CXX_COMPILER_WORKS=ON"
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
] ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
"-DCOMPILER_RT_BUILD_XRAY=OFF"
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.parsed.kernel.name == "none") [
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
"-DCOMPILER_RT_OS_DIR=baremetal"
];
outputs = [ "out" "dev" ];
patches = [
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
./compiler-rt-genode.patch
]# ++ stdenv.lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
++ stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ./crtbegin-and-end.patch;
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
# a flag and turn the flag off during the stdenv build.
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
'' + stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
substituteInPlace lib/builtins/int_util.c \
--replace "#include <stdlib.h>" ""
substituteInPlace lib/builtins/clear_cache.c \
--replace "#include <assert.h>" ""
substituteInPlace lib/builtins/cpu_model.c \
--replace "#include <assert.h>" ""
'';
# Hack around weird upsream RPATH bug
postInstall = stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
ln -s "$out/lib"/*/* "$out/lib"
'' + stdenv.lib.optionalString (stdenv.hostPlatform.useLLVM or false) ''
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
'';
enableParallelBuilding = true;
}

View File

@ -0,0 +1,13 @@
diff --git a/lib/builtins/assembly.h b/lib/builtins/assembly.h
index 3f5e59b2544..97d06d6ccd1 100644
--- a/lib/builtins/assembly.h
+++ b/lib/builtins/assembly.h
@@ -45,7 +45,7 @@
#define CONST_SECTION .section .rodata
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
- defined(__linux__)
+ defined(__linux__) || defined(__GENODE__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE

View File

@ -0,0 +1,595 @@
Get crtbegin and crtend without compiler GCC! PR is at https://reviews.llvm.org/D28791
Index: compiler-rt/CMakeLists.txt
===================================================================
--- compiler-rt/CMakeLists.txt
+++ compiler-rt/CMakeLists.txt
@@ -29,6 +29,8 @@
option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
+option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON)
+mark_as_advanced(COMPILER_RT_BUILD_CRT)
option(COMPILER_RT_BUILD_SANITIZERS "Build sanitizers" ON)
mark_as_advanced(COMPILER_RT_BUILD_SANITIZERS)
option(COMPILER_RT_BUILD_XRAY "Build xray" ON)
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -132,7 +132,7 @@
# Adds static or shared runtime for a list of architectures and operating
# systems and puts it in the proper directory in the build and install trees.
# add_compiler_rt_runtime(<name>
-# {STATIC|SHARED}
+# {OBJECT|STATIC|SHARED}
# ARCHS <architectures>
# OS <os list>
# SOURCES <source files>
@@ -144,8 +144,8 @@
# PARENT_TARGET <convenience parent target>
# ADDITIONAL_HEADERS <header files>)
function(add_compiler_rt_runtime name type)
- if(NOT type MATCHES "^(STATIC|SHARED)$")
- message(FATAL_ERROR "type argument must be STATIC or SHARED")
+ if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$")
+ message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED")
return()
endif()
cmake_parse_arguments(LIB
@@ -204,7 +204,10 @@
message(FATAL_ERROR "Architecture ${arch} can't be targeted")
return()
endif()
- if(type STREQUAL "STATIC")
+ if(type STREQUAL "OBJECT")
+ set(libname "${name}-${arch}")
+ set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
+ elseif(type STREQUAL "STATIC")
set(libname "${name}-${arch}")
set_output_name(output_name_${libname} ${name} ${arch})
else()
@@ -270,12 +273,34 @@
set(COMPONENT_OPTION COMPONENT ${libname})
endif()
- add_library(${libname} ${type} ${sources_${libname}})
- set_target_compile_flags(${libname} ${extra_cflags_${libname}})
- set_target_link_flags(${libname} ${extra_link_flags_${libname}})
- set_property(TARGET ${libname} APPEND PROPERTY
- COMPILE_DEFINITIONS ${LIB_DEFS})
- set_target_output_directories(${libname} ${output_dir_${libname}})
+ if(type STREQUAL "OBJECT")
+ string(TOUPPER ${CMAKE_BUILD_TYPE} config)
+ get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS)
+ separate_arguments(cflags)
+ add_custom_command(
+ OUTPUT ${output_dir_${libname}}/${libname}.o
+ COMMAND ${CMAKE_C_COMPILER} ${sources_${libname}} ${cflags} ${extra_cflags_${libname}} -c -o ${output_dir_${libname}}/${libname}.o
+ DEPENDS ${sources_${libname}}
+ COMMENT "Building C object ${libname}.o")
+ add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${libname}.o)
+ install(FILES ${output_dir_${libname}}/${libname}.o
+ DESTINATION ${install_dir_${libname}}
+ ${COMPONENT_OPTION})
+ else()
+ add_library(${libname} ${type} ${sources_${libname}})
+ set_target_compile_flags(${libname} ${extra_cflags_${libname}})
+ set_target_link_flags(${libname} ${extra_link_flags_${libname}})
+ set_property(TARGET ${libname} APPEND PROPERTY
+ COMPILE_DEFINITIONS ${LIB_DEFS})
+ set_target_output_directories(${libname} ${output_dir_${libname}})
+ install(TARGETS ${libname}
+ ARCHIVE DESTINATION ${install_dir_${libname}}
+ ${COMPONENT_OPTION}
+ LIBRARY DESTINATION ${install_dir_${libname}}
+ ${COMPONENT_OPTION}
+ RUNTIME DESTINATION ${install_dir_${libname}}
+ ${COMPONENT_OPTION})
+ endif()
set_target_properties(${libname} PROPERTIES
OUTPUT_NAME ${output_name_${libname}})
set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime")
@@ -299,13 +324,6 @@
)
endif()
endif()
- install(TARGETS ${libname}
- ARCHIVE DESTINATION ${install_dir_${libname}}
- ${COMPONENT_OPTION}
- LIBRARY DESTINATION ${install_dir_${libname}}
- ${COMPONENT_OPTION}
- RUNTIME DESTINATION ${install_dir_${libname}}
- ${COMPONENT_OPTION})
# We only want to generate per-library install targets if you aren't using
# an IDE because the extra targets get cluttered in IDEs.
Index: compiler-rt/cmake/config-ix.cmake
===================================================================
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -227,6 +227,7 @@
${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X})
set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
${MIPS32} ${MIPS64} ${PPC64} ${S390X})
+set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64})
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64})
@@ -474,6 +475,7 @@
SANITIZER_COMMON_SUPPORTED_ARCH)
else()
+ filter_available_targets(CRT_SUPPORTED_ARCH ${ALL_CRT_SUPPORTED_ARCH})
# Architectures supported by compiler-rt libraries.
filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH
${ALL_SANITIZER_COMMON_SUPPORTED_ARCH})
@@ -563,6 +565,12 @@
# TODO: Add builtins support.
+if (CRT_SUPPORTED_ARCH AND OS_NAME MATCHES "Linux")
+ set(COMPILER_RT_HAS_CRT TRUE)
+else()
+ set(COMPILER_RT_HAS_CRT FALSE)
+endif()
+
if (COMPILER_RT_HAS_SANITIZER_COMMON AND DFSAN_SUPPORTED_ARCH AND
OS_NAME MATCHES "Linux")
set(COMPILER_RT_HAS_DFSAN TRUE)
Index: compiler-rt/lib/CMakeLists.txt
===================================================================
--- compiler-rt/lib/CMakeLists.txt
+++ compiler-rt/lib/CMakeLists.txt
@@ -17,6 +17,10 @@
add_subdirectory(builtins)
endif()
+if(COMPILER_RT_BUILD_CRT)
+ add_subdirectory(crt)
+endif()
+
function(compiler_rt_build_runtime runtime)
string(TOUPPER ${runtime} runtime_uppercase)
if(COMPILER_RT_HAS_${runtime_uppercase})
Index: compiler-rt/lib/crt/CMakeLists.txt
===================================================================
--- /dev/null
+++ compiler-rt/lib/crt/CMakeLists.txt
@@ -0,0 +1,102 @@
+add_compiler_rt_component(crt)
+
+function(check_cxx_section_exists section output)
+ cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN})
+ if(NOT ARG_SOURCE)
+ set(ARG_SOURCE "int main() { return 0; }\n")
+ endif()
+
+ string(RANDOM TARGET_NAME)
+ set(TARGET_NAME "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cmTC_${TARGET_NAME}.dir")
+ file(MAKE_DIRECTORY ${TARGET_NAME})
+
+ file(WRITE "${TARGET_NAME}/CheckSectionExists.c" "${ARG_SOURCE}\n")
+
+ string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions
+ ${CMAKE_C_COMPILE_OBJECT})
+
+ set(try_compile_flags "${ARG_FLAGS}")
+ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET)
+ list(APPEND try_compile_flags "-target ${CMAKE_C_COMPILER_TARGET}")
+ endif()
+
+ string(REPLACE ";" " " extra_flags "${try_compile_flags}")
+
+ set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}")
+ foreach(substitution ${substitutions})
+ if(substitution STREQUAL "<CMAKE_C_COMPILER>")
+ string(REPLACE "<CMAKE_C_COMPILER>"
+ "${CMAKE_C_COMPILER}" test_compile_command ${test_compile_command})
+ elseif(substitution STREQUAL "<OBJECT>")
+ string(REPLACE "<OBJECT>" "${TARGET_NAME}/CheckSectionExists.o"
+ test_compile_command ${test_compile_command})
+ elseif(substitution STREQUAL "<SOURCE>")
+ string(REPLACE "<SOURCE>" "${TARGET_NAME}/CheckSectionExists.c"
+ test_compile_command ${test_compile_command})
+ elseif(substitution STREQUAL "<FLAGS>")
+ string(REPLACE "<FLAGS>" "${CMAKE_C_FLAGS} ${extra_flags}"
+ test_compile_command ${test_compile_command})
+ else()
+ string(REPLACE "${substitution}" "" test_compile_command
+ ${test_compile_command})
+ endif()
+ endforeach()
+
+ string(REPLACE " " ";" test_compile_command "${test_compile_command}")
+
+ execute_process(
+ COMMAND ${test_compile_command}
+ RESULT_VARIABLE TEST_RESULT
+ OUTPUT_VARIABLE TEST_OUTPUT
+ ERROR_VARIABLE TEST_ERROR
+ )
+
+ execute_process(
+ COMMAND ${CMAKE_OBJDUMP} -h "${TARGET_NAME}/CheckSectionExists.o"
+ RESULT_VARIABLE CHECK_RESULT
+ OUTPUT_VARIABLE CHECK_OUTPUT
+ ERROR_VARIABLE CHECK_ERROR
+ )
+ string(FIND "${CHECK_OUTPUT}" "${section}" SECTION_FOUND)
+
+ if(NOT SECTION_FOUND EQUAL -1)
+ set(${output} TRUE PARENT_SCOPE)
+ else()
+ set(${output} FALSE PARENT_SCOPE)
+ endif()
+
+ file(REMOVE_RECURSE ${TARGET_NAME})
+endfunction()
+
+check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY
+ SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n")
+
+append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS)
+append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS)
+
+foreach(arch ${CRT_SUPPORTED_ARCH})
+ add_compiler_rt_runtime(clang_rt.crtbegin
+ OBJECT
+ ARCHS ${arch}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
+ CFLAGS ${CRT_CFLAGS}
+ PARENT_TARGET crt)
+ add_compiler_rt_runtime(clang_rt.crtbegin_shared
+ OBJECT
+ ARCHS ${arch}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
+ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED
+ PARENT_TARGET crt)
+ add_compiler_rt_runtime(clang_rt.crtend
+ OBJECT
+ ARCHS ${arch}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c
+ CFLAGS ${CRT_CFLAGS}
+ PARENT_TARGET crt)
+ add_compiler_rt_runtime(clang_rt.crtend_shared
+ OBJECT
+ ARCHS ${arch}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c
+ CFLAGS ${CRT_CFLAGS} -DCRT_SHARED
+ PARENT_TARGET crt)
+endforeach()
Index: compiler-rt/lib/crt/crtbegin.c
===================================================================
--- /dev/null
+++ compiler-rt/lib/crt/crtbegin.c
@@ -0,0 +1,108 @@
+/* ===-- crtbegin.c - Start of constructors and destructors ----------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#include <stddef.h>
+
+__attribute__((visibility("hidden")))
+#ifdef CRT_SHARED
+void *__dso_handle = &__dso_handle;
+#else
+void *__dso_handle = (void *)0;
+#endif
+
+static long __EH_FRAME_LIST__[]
+ __attribute__((section(".eh_frame"), aligned(sizeof(void *)))) = {};
+
+extern void __register_frame_info(const void *, void *) __attribute__((weak));
+extern void *__deregister_frame_info(const void *) __attribute__((weak));
+
+#ifndef CRT_HAS_INITFINI_ARRAY
+typedef void (*fp)(void);
+
+static fp __CTOR_LIST__[]
+ __attribute__((section(".ctors"), aligned(sizeof(fp)), used)) = {(fp)-1};
+extern fp __CTOR_LIST_END__[];
+#endif
+
+#ifdef CRT_SHARED
+extern void __cxa_finalize(void *) __attribute__((weak));
+#endif
+
+static void __attribute__((used)) __do_init() {
+ static _Bool __initialized;
+ if (__builtin_expect(__initialized, 0))
+ return;
+ __initialized = 1;
+
+ static struct { void *p[8]; } __object;
+ if (__register_frame_info)
+ __register_frame_info(__EH_FRAME_LIST__, &__object);
+
+#ifndef CRT_HAS_INITFINI_ARRAY
+ const size_t n = __CTOR_LIST_END__ - __CTOR_LIST__ - 1;
+ for (size_t i = n; i >= 1; i--) __CTOR_LIST__[i]();
+#endif
+}
+
+#ifdef CRT_HAS_INITFINI_ARRAY
+__attribute__((section(".init_array"),
+ used)) static void (*__init)(void) = __do_init;
+#else // CRT_HAS_INITFINI_ARRAY
+#if defined(__i386__) || defined(__x86_64__)
+asm(".pushsection .init,\"ax\",@progbits\n\t"
+ "call " __USER_LABEL_PREFIX__ "__do_init\n\t"
+ ".popsection");
+#elif defined(__arm__)
+asm(".pushsection .init,\"ax\",%progbits\n\t"
+ "bl " __USER_LABEL_PREFIX__ "__do_init\n\t"
+ ".popsection");
+#endif // CRT_HAS_INITFINI_ARRAY
+#endif
+
+#ifndef CRT_HAS_INITFINI_ARRAY
+static fp __DTOR_LIST__[]
+ __attribute__((section(".dtors"), aligned(sizeof(fp)), used)) = {(fp)-1};
+extern fp __DTOR_LIST_END__[];
+#endif
+
+static void __attribute__((used)) __do_fini() {
+ static _Bool __finalized;
+ if (__builtin_expect(__finalized, 0))
+ return;
+ __finalized = 1;
+
+#ifdef CRT_SHARED
+ if (__cxa_finalize)
+ __cxa_finalize(__dso_handle);
+#endif
+
+#ifndef CRT_HAS_INITFINI_ARRAY
+ if (__deregister_frame_info)
+ __deregister_frame_info(__EH_FRAME_LIST__);
+
+ const size_t n = __DTOR_LIST_END__ - __DTOR_LIST__ - 1;
+ for (size_t i = 1; i < n; i++) __DTOR_LIST__[i]();
+#endif
+}
+
+#ifdef CRT_HAS_INITFINI_ARRAY
+__attribute__((section(".fini_array"),
+ used)) static void (*__fini)(void) = __do_fini;
+#else // CRT_HAS_INITFINI_ARRAY
+#if defined(__i386__) || defined(__x86_64__)
+asm(".pushsection .fini,\"ax\",@progbits\n\t"
+ "call " __USER_LABEL_PREFIX__ "__do_fini\n\t"
+ ".popsection");
+#elif defined(__arm__)
+asm(".pushsection .fini,\"ax\",%progbits\n\t"
+ "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t"
+ ".popsection");
+#endif
+#endif // CRT_HAS_INIT_FINI_ARRAY
Index: compiler-rt/lib/crt/crtend.c
===================================================================
--- /dev/null
+++ compiler-rt/lib/crt/crtend.c
@@ -0,0 +1,24 @@
+/* ===-- crtend.c - End of constructors and destructors --------------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#include <stdint.h>
+
+// Put 4-byte zero which is the length field in FDE at the end as a terminator.
+const int32_t __EH_FRAME_LIST_END__[]
+ __attribute__((section(".eh_frame"), aligned(sizeof(int32_t)),
+ visibility("hidden"), used)) = {0};
+
+#ifndef CRT_HAS_INITFINI_ARRAY
+typedef void (*fp)(void);
+fp __CTOR_LIST_END__[]
+ __attribute__((section(".ctors"), visibility("hidden"), used)) = {0};
+fp __DTOR_LIST_END__[]
+ __attribute__((section(".dtors"), visibility("hidden"), used)) = {0};
+#endif
Index: compiler-rt/test/CMakeLists.txt
===================================================================
--- compiler-rt/test/CMakeLists.txt
+++ compiler-rt/test/CMakeLists.txt
@@ -73,6 +73,9 @@
if(COMPILER_RT_BUILD_XRAY)
compiler_rt_test_runtime(xray)
endif()
+ if(COMPILER_RT_HAS_CRT)
+ add_subdirectory(crt)
+ endif()
# ShadowCallStack does not yet provide a runtime with compiler-rt, the tests
# include their own minimal runtime
add_subdirectory(shadowcallstack)
Index: compiler-rt/test/crt/CMakeLists.txt
===================================================================
--- /dev/null
+++ compiler-rt/test/crt/CMakeLists.txt
@@ -0,0 +1,31 @@
+set(CRT_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+set(CRT_TESTSUITES)
+
+set(CRT_TEST_DEPS "")
+
+if(NOT COMPILER_RT_STANDALONE_BUILD AND COMPILER_RT_BUILD_CRT AND
+ COMPILER_RT_HAS_CRT)
+ list(APPEND CRT_TEST_DEPS crt)
+endif()
+
+set(CRT_TEST_ARCH ${CRT_SUPPORTED_ARCH})
+if (COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT)
+ foreach(arch ${CRT_TEST_ARCH})
+ set(CRT_TEST_TARGET_ARCH ${arch})
+ string(TOLOWER "-${arch}-${OS_NAME}" CRT_TEST_CONFIG_SUFFIX)
+ get_test_cc_for_arch(${arch} CRT_TEST_TARGET_CC CRT_TEST_TARGET_CFLAGS)
+ string(TOUPPER ${arch} ARCH_UPPER_CASE)
+ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
+
+ configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
+ list(APPEND CRT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+ endforeach()
+endif()
+
+add_lit_testsuite(check-crt "Running the CRT tests"
+ ${CRT_TESTSUITES}
+ DEPENDS ${CRT_TEST_DEPS})
+set_target_properties(check-crt PROPERTIES FOLDER "Compiler-RT Misc")
Index: compiler-rt/test/crt/dso_handle.cpp
===================================================================
--- /dev/null
+++ compiler-rt/test/crt/dso_handle.cpp
@@ -0,0 +1,33 @@
+// RUN: %clangxx -g -DCRT_SHARED -c %s -fPIC -o %tshared.o
+// RUN: %clangxx -g -c %s -fPIC -o %t.o
+// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %shared_crtbegin %tshared.o %libstdcxx -lc -lm -lgcc_s %shared_crtend %crtn
+// RUN: %clangxx -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+
+// CHECK: 1
+// CHECK-NEXT: ~A()
+
+#ifdef CRT_SHARED
+bool G;
+void C() {
+ printf("%d\n", G);
+}
+
+struct A {
+ A() { G = true; }
+ ~A() {
+ printf("~A()\n");
+ }
+};
+
+A a;
+#else
+void C();
+
+int main() {
+ C();
+ return 0;
+}
+#endif
Index: compiler-rt/test/crt/lit.cfg
===================================================================
--- /dev/null
+++ compiler-rt/test/crt/lit.cfg
@@ -0,0 +1,80 @@
+# -*- Python -*-
+
+import os
+import subprocess
+
+# Setup config name.
+config.name = 'CRT' + config.name_suffix
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+
+def get_library_path(file):
+ cmd = subprocess.Popen([config.clang.strip(),
+ config.target_cflags.strip(),
+ '-print-file-name=%s' % file],
+ stdout=subprocess.PIPE,
+ env=config.environment)
+ if not cmd.stdout:
+ lit_config.fatal("Couldn't find the library path for '%s'" % file)
+ dir = cmd.stdout.read().strip()
+ if sys.platform in ['win32'] and execute_external:
+ # Don't pass dosish path separator to msys bash.exe.
+ dir = dir.replace('\\', '/')
+ # Ensure the result is an ascii string, across Python2.5+ - Python3.
+ return str(dir.decode('ascii'))
+
+
+def get_libgcc_file_name():
+ cmd = subprocess.Popen([config.clang.strip(),
+ config.target_cflags.strip(),
+ '-print-libgcc-file-name'],
+ stdout=subprocess.PIPE,
+ env=config.environment)
+ if not cmd.stdout:
+ lit_config.fatal("Couldn't find the library path for '%s'" % file)
+ dir = cmd.stdout.read().strip()
+ if sys.platform in ['win32'] and execute_external:
+ # Don't pass dosish path separator to msys bash.exe.
+ dir = dir.replace('\\', '/')
+ # Ensure the result is an ascii string, across Python2.5+ - Python3.
+ return str(dir.decode('ascii'))
+
+
+def build_invocation(compile_flags):
+ return ' ' + ' '.join([config.clang] + compile_flags) + ' '
+
+
+# Setup substitutions.
+config.substitutions.append(
+ ('%clang ', build_invocation([config.target_cflags])))
+config.substitutions.append(
+ ('%clangxx ',
+ build_invocation(config.cxx_mode_flags + [config.target_cflags])))
+
+base_lib = os.path.join(
+ config.compiler_rt_libdir, "clang_rt.%%s-%s.o" % config.target_arch)
+config.substitutions.append(('%crtbegin', base_lib % "crtbegin"))
+config.substitutions.append(('%shared_crtbegin', base_lib % "crtbegin_shared"))
+config.substitutions.append(('%crtend', base_lib % "crtend"))
+config.substitutions.append(('%shared_crtend', base_lib % "crtend_shared"))
+
+config.substitutions.append(
+ ('%crt1', get_library_path('crt1.o')))
+config.substitutions.append(
+ ('%crti', get_library_path('crti.o')))
+config.substitutions.append(
+ ('%crtn', get_library_path('crtn.o')))
+
+config.substitutions.append(
+ ('%libgcc', get_libgcc_file_name()))
+
+config.substitutions.append(
+ ('%libstdcxx', '-l' + config.sanitizer_cxx_lib.lstrip('lib')))
+
+# Default test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp']
+
+if config.host_os not in ['Linux']:
+ config.unsupported = True
Index: compiler-rt/test/crt/lit.site.cfg.in
===================================================================
--- /dev/null
+++ compiler-rt/test/crt/lit.site.cfg.in
@@ -0,0 +1,14 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+# Tool-specific config options.
+config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@"
+config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@"
+config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@"
+config.target_arch = "@CRT_TEST_TARGET_ARCH@"
+config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@"
+
+# Load common config for all compiler-rt lit tests
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg")

201
overlay/llvm-8/default.nix Normal file
View File

@ -0,0 +1,201 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ lowPrio, newScope, pkgs, stdenv, cmake, libstdcxxHook
, libxml2, python, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
, buildLlvmTools # tools, but from the previous stage, for cross
, targetLlvmLibraries # libraries, but from the next stage, for cross
}:
let
release_version = "8.0.1";
version = release_version; # differentiating these is important for rc's
fetch = name: sha256: fetchurl {
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${release_version}/${name}-${version}.src.tar.xz";
inherit sha256;
};
clang-tools-extra_src = fetch "clang-tools-extra" "1qf3097bc5ia8p6cpmbx985rjr3yaah5s8fc0nv7pw742yv7jw8q";
tools = stdenv.lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
mkExtraBuildCommands = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (stdenv.targetPlatform.isLinux && tools.clang-unwrapped ? gcc && !(stdenv.targetPlatform.useLLVM or false)) ''
echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags
'';
in {
llvm = callPackage ./llvm.nix { };
llvm-polly = callPackage ./llvm.nix { enablePolly = true; };
clang-unwrapped = callPackage ./clang {
inherit clang-tools-extra_src;
};
clang-polly-unwrapped = callPackage ./clang {
inherit clang-tools-extra_src;
llvm = tools.llvm-polly;
enablePolly = true;
};
llvm-manpages = lowPrio (tools.llvm.override {
enableManpages = true;
python = pkgs.python; # don't use python-boot
});
clang-manpages = lowPrio (tools.clang-unwrapped.override {
enableManpages = true;
python = pkgs.python; # don't use python-boot
});
libclang = tools.clang-unwrapped.lib;
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
libstdcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
extraPackages = [
libstdcxxHook
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
};
libcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
extraPackages = [
targetLlvmLibraries.libcxx
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
};
lld = callPackage ./lld.nix {};
lldb = callPackage ./lldb.nix {};
# Below, is the LLVM bootstrapping logic. It handles building a
# fully LLVM toolchain from scratch. No GCC toolchain should be
# pulled in. As a consequence, it is very quick to build different
# targets provided by LLVM and we can also build for what GCC
# doesnt support like LLVM. Probably we should move to some other
# file.
bintools = callPackage ./bintools.nix {};
lldClang = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = targetLlvmLibraries.libcxx;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
extraPackages = [
targetLlvmLibraries.libcxx
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
] ++ stdenv.lib.optionals (!stdenv.targetPlatform.isGenode && !stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind
];
extraBuildCommands = ''
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString (!stdenv.targetPlatform.isWasm) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString stdenv.targetPlatform.isWasm ''
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoLibcxx = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
};
extraPackages = [
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = ''
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
echo "-nostdlib++" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoLibc = wrapCCWith rec {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
extraPackages = [
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = ''
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
'' + mkExtraBuildCommands cc;
};
lldClangNoCompilerRt = wrapCCWith {
cc = tools.clang-unwrapped;
libcxx = null;
bintools = wrapBintoolsWith {
inherit (tools) bintools;
libc = null;
};
extraPackages = [ ];
extraBuildCommands = ''
echo "-nostartfiles" >> $out/nix-support/cc-cflags
echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags
'';
};
});
libraries = stdenv.lib.makeExtensible (libraries: let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python isl release_version version fetch; });
in {
compiler-rt = callPackage ./compiler-rt.nix ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
}));
stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
libcxx = callPackage ./libc++ ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
libcxxabi = callPackage ./libc++abi.nix ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
libunwind = libraries.libunwind;
}));
openmp = callPackage ./openmp.nix {};
libunwind = callPackage ./libunwind.nix ({} //
(stdenv.lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoLibcxx;
}));
});
in { inherit tools libraries; } // libraries // tools

498
overlay/llvm-8/genode.patch Normal file
View File

@ -0,0 +1,498 @@
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 3c139d72479..89d6df3f5b4 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -147,6 +147,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new FreeBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<AArch64leTargetInfo>(Triple, Opts);
+ case llvm::Triple::Genode:
+ return new GenodeTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple, Opts);
case llvm::Triple::NetBSD:
@@ -171,6 +173,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new FreeBSDTargetInfo<AArch64beTargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<AArch64beTargetInfo>(Triple, Opts);
+ case llvm::Triple::Genode:
+ return new GenodeTargetInfo<AArch64beTargetInfo>(Triple, Opts);
case llvm::Triple::Linux:
return new LinuxTargetInfo<AArch64beTargetInfo>(Triple, Opts);
case llvm::Triple::NetBSD:
@@ -528,6 +532,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Fuchsia:
return new FuchsiaTargetInfo<X86_64TargetInfo>(Triple, Opts);
+ case llvm::Triple::Genode:
+ return new GenodeTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::KFreeBSD:
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::Solaris:
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 09867d82c38..f67151a13e8 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -760,6 +760,26 @@ public:
}
};
+// Genode Target
+template <typename Target>
+class LLVM_LIBRARY_VISIBILITY GenodeTargetInfo : public OSTargetInfo<Target> {
+protected:
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+ MacroBuilder &Builder) const override {
+ Builder.defineMacro("__GENODE__");
+ Builder.defineMacro("__ELF__");
+ // Required by the libc++ locale support.
+ if (Opts.CPlusPlus)
+ Builder.defineMacro("_GNU_SOURCE");
+ }
+
+public:
+ GenodeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ : OSTargetInfo<Target>(Triple, Opts) {
+ this->MCountName = "__mcount";
+ }
+};
+
// WebAssembly target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 4793a1f90b2..4691b898eb2 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -44,6 +44,7 @@ add_clang_library(clangDriver
ToolChains/DragonFly.cpp
ToolChains/FreeBSD.cpp
ToolChains/Fuchsia.cpp
+ ToolChains/Genode.cpp
ToolChains/Gnu.cpp
ToolChains/Haiku.cpp
ToolChains/HIP.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a784e218f13..881b78abc4d 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -22,6 +22,7 @@
#include "ToolChains/DragonFly.h"
#include "ToolChains/FreeBSD.h"
#include "ToolChains/Fuchsia.h"
+#include "ToolChains/Genode.h"
#include "ToolChains/Gnu.h"
#include "ToolChains/HIP.h"
#include "ToolChains/Haiku.h"
@@ -4570,6 +4571,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::Solaris:
TC = llvm::make_unique<toolchains::Solaris>(*this, Target, Args);
break;
+ case llvm::Triple::Genode:
+ TC = llvm::make_unique<toolchains::Genode>(*this, Target, Args);
+ break;
case llvm::Triple::AMDHSA:
TC = llvm::make_unique<toolchains::AMDGPUToolChain>(*this, Target, Args);
break;
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 1a46073aaa3..72b6f7389a3 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -693,7 +693,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
ImplicitCfiRuntime = TC.getTriple().isAndroid();
if (AllAddedKinds & Address) {
- NeedPIE |= TC.getTriple().isOSFuchsia();
+ NeedPIE |= TC.getTriple().isOSFuchsia() | TC.getTriple().isOSGenode();
if (Arg *A =
Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
StringRef S = A->getValue();
diff --git a/clang/lib/Driver/ToolChains/Genode.cpp b/clang/lib/Driver/ToolChains/Genode.cpp
new file mode 100644
index 00000000000..52ed73ae0b4
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Genode.cpp
@@ -0,0 +1,86 @@
+//===--- Genode.cpp - CloudABI ToolChain Implementations --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#include "Genode.h"
+#include "InputInfo.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/Options.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang::driver;
+using namespace clang::driver::tools;
+using namespace clang::driver::toolchains;
+using namespace clang;
+using namespace llvm::opt;
+
+void genode::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const llvm::opt::ArgList &Args,
+ const char *LinkingOutput) const {
+ const ToolChain &ToolChain = getToolChain();
+ const Driver &D = ToolChain.getDriver();
+ ArgStringList CmdArgs;
+
+ if (Output.isFilename()) {
+ CmdArgs.push_back("-o");
+ CmdArgs.push_back(Output.getFilename());
+ } else {
+ assert(Output.isNothing() && "Invalid output.");
+ }
+
+ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
+
+ const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
+}
+
+Genode::Genode(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args)
+ : Generic_ELF(D, Triple, Args) {
+ SmallString<128> P(getDriver().Dir);
+ llvm::sys::path::append(P, "..", getTriple().str(), "lib");
+ getFilePaths().push_back(P.str());
+}
+
+void Genode::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const {
+ SmallString<128> P(getDriver().Dir);
+ llvm::sys::path::append(P, "..", getTriple().str(), "include/c++/v1");
+ addSystemInclude(DriverArgs, CC1Args, P.str());
+}
+
+bool Genode::isPIEDefault() const {
+ switch (getTriple().getArch()) {
+ case llvm::Triple::aarch64:
+ case llvm::Triple::x86_64:
+ return true;
+ default:
+ return false;
+ }
+}
+
+SanitizerMask Genode::getSupportedSanitizers() const {
+ SanitizerMask Res = Generic_ELF::getSupportedSanitizers();
+ Res |= SanitizerKind::SafeStack;
+ return Res;
+}
+
+SanitizerMask Genode::getDefaultSanitizers() const {
+ return SanitizerKind::SafeStack;
+}
+
+Tool *Genode::buildLinker() const {
+ return new tools::genode::Linker(*this);
+}
diff --git a/clang/lib/Driver/ToolChains/Genode.h b/clang/lib/Driver/ToolChains/Genode.h
new file mode 100644
index 00000000000..971efb04ef9
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Genode.h
@@ -0,0 +1,69 @@
+//===----- Genode.h - CloudABI ToolChain Implementations --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
+
+#include "Gnu.h"
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+
+//// genode -- Directly call GNU Binutils linker
+namespace genode {
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+ Linker(const ToolChain &TC) : GnuTool("genode::Linker", "linker", TC) {}
+
+ bool hasIntegratedCPP() const override { return false; }
+ bool isLinkJob() const override { return true; }
+
+ void ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output, const InputInfoList &Inputss,
+ const llvm::opt::ArgList &Args,
+ const char *LinkingOutput) const override;
+};
+} // end namespace genode
+} // end namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY Genode : public Generic_ELF {
+public:
+ Genode(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args);
+ bool HasNativeLLVMSupport() const override { return true; }
+
+ bool IsMathErrnoDefault() const override { return true; }
+
+ CXXStdlibType
+ GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
+ return ToolChain::CST_Libcxx;
+ }
+ void addLibCxxIncludePaths(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+
+ bool isPIEDefault() const override;
+ SanitizerMask getSupportedSanitizers() const override;
+ SanitizerMask getDefaultSanitizers() const override;
+
+protected:
+ Tool *buildLinker() const override;
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_GENODE_H
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index 67842b5dca2..26a2c65fec2 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -221,6 +221,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::PS4:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Fuchsia:
+ case llvm::Triple::Genode:
break;
case llvm::Triple::Win32:
if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -329,6 +330,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::NaCl:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Fuchsia:
+ case llvm::Triple::Genode:
break;
case llvm::Triple::PS4: {
// <isysroot> gets prepended later in AddPath().
diff --git a/clang/test/Driver/genode.c b/clang/test/Driver/genode.c
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/clang/test/Driver/genode.cpp b/clang/test/Driver/genode.cpp
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/compiler-rt/lib/builtins/assembly.h b/compiler-rt/lib/builtins/assembly.h
index 3f5e59b2544..97d06d6ccd1 100644
--- a/compiler-rt/lib/builtins/assembly.h
+++ b/compiler-rt/lib/builtins/assembly.h
@@ -45,7 +45,7 @@
#define CONST_SECTION .section .rodata
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
- defined(__linux__)
+ defined(__linux__) || defined(__GENODE__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE
diff --git a/libcxx/utils/google-benchmark/src/internal_macros.h b/libcxx/utils/google-benchmark/src/internal_macros.h
index 5dbf4fd2752..4699c5ed913 100644
--- a/libcxx/utils/google-benchmark/src/internal_macros.h
+++ b/libcxx/utils/google-benchmark/src/internal_macros.h
@@ -70,6 +70,8 @@
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
+#elif defined(__GENODE__)
+ #define BENCHMARK_OS_GENODE 1
#endif
#if defined(__ANDROID__) && defined(__GLIBCXX__)
diff --git a/libunwind/src/assembly.h b/libunwind/src/assembly.h
index 0b7d24389a4..84cb7bf2f8b 100644
--- a/libunwind/src/assembly.h
+++ b/libunwind/src/assembly.h
@@ -71,7 +71,7 @@
#define HIDDEN_SYMBOL(name) .hidden name
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
- defined(__linux__)
+ defined(__linux__) || defined(__GENODE__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 49db3088bbc..32ffed3cb2e 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -107,7 +107,7 @@ if(WIN32)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
else(WIN32)
- if(FUCHSIA OR UNIX)
+ if(FUCHSIA OR GENODE OR UNIX)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
@@ -115,9 +115,9 @@ else(WIN32)
else()
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif()
- else(FUCHSIA OR UNIX)
+ else(FUCHSIA OR GENODE OR UNIX)
MESSAGE(SEND_ERROR "Unable to determine platform")
- endif(FUCHSIA OR UNIX)
+ endif(FUCHSIA OR GENODE OR UNIX)
endif(WIN32)
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index e06a68e2731..7da3d5d29bc 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -159,6 +159,7 @@ public:
DragonFly,
FreeBSD,
Fuchsia,
+ Genode,
IOS,
KFreeBSD,
Linux,
@@ -498,6 +499,8 @@ public:
bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
+ bool isOSGenode() const { return getOS() == Triple::Genode; }
+
bool isOSSolaris() const {
return getOS() == Triple::Solaris;
}
diff --git a/llvm/include/llvm/BinaryFormat/ELF.h b/llvm/include/llvm/BinaryFormat/ELF.h
index ce35d127d43..d7a589057db 100644
--- a/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/llvm/include/llvm/BinaryFormat/ELF.h
@@ -348,6 +348,7 @@ enum {
ELFOSABI_AROS = 15, // AROS
ELFOSABI_FENIXOS = 16, // FenixOS
ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
+ ELFOSABI_GENODE = 18, // Genode
ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
diff --git a/llvm/include/llvm/MC/MCELFObjectWriter.h b/llvm/include/llvm/MC/MCELFObjectWriter.h
index f226d6a45a5..91efe079d20 100644
--- a/llvm/include/llvm/MC/MCELFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCELFObjectWriter.h
@@ -74,6 +74,8 @@ public:
switch (OSType) {
case Triple::CloudABI:
return ELF::ELFOSABI_CLOUDABI;
+ case Triple::Genode:
+ return ELF::ELFOSABI_GENODE;
case Triple::HermitCore:
return ELF::ELFOSABI_STANDALONE;
case Triple::PS4:
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 215d6bdd091..0d3f5eaf032 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -260,6 +260,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
ECase(ELFOSABI_AROS);
ECase(ELFOSABI_FENIXOS);
ECase(ELFOSABI_CLOUDABI);
+ ECase(ELFOSABI_GENODE);
ECase(ELFOSABI_AMDGPU_HSA);
ECase(ELFOSABI_AMDGPU_PAL);
ECase(ELFOSABI_AMDGPU_MESA3D);
diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 26d9327f620..1866b07ac68 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -181,6 +181,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case DragonFly: return "dragonfly";
case FreeBSD: return "freebsd";
case Fuchsia: return "fuchsia";
+ case Genode: return "genode";
case IOS: return "ios";
case KFreeBSD: return "kfreebsd";
case Linux: return "linux";
@@ -478,6 +479,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("dragonfly", Triple::DragonFly)
.StartsWith("freebsd", Triple::FreeBSD)
.StartsWith("fuchsia", Triple::Fuchsia)
+ .StartsWith("genode", Triple::Genode)
.StartsWith("ios", Triple::IOS)
.StartsWith("kfreebsd", Triple::KFreeBSD)
.StartsWith("linux", Triple::Linux)
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 93254717e92..3d96ff9332a 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -911,6 +911,7 @@ static const EnumEntry<unsigned> ElfOSABI[] = {
{"AROS", "AROS", ELF::ELFOSABI_AROS},
{"FenixOS", "FenixOS", ELF::ELFOSABI_FENIXOS},
{"CloudABI", "CloudABI", ELF::ELFOSABI_CLOUDABI},
+ {"Genode", "Genode", ELF::ELFOSABI_GENODE},
{"Standalone", "Standalone App", ELF::ELFOSABI_STANDALONE}
};
diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp
index bc7f9321caa..5d6a56d7723 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -241,6 +241,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Fuchsia, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+ T = Triple("x86_64-unknown-genode");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::Genode, T.getOS());
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
T = Triple("x86_64-unknown-hermit");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
diff --git a/llvm/utils/benchmark/src/internal_macros.h b/llvm/utils/benchmark/src/internal_macros.h
index f2d54bfcbd9..e20f891d435 100644
--- a/llvm/utils/benchmark/src/internal_macros.h
+++ b/llvm/utils/benchmark/src/internal_macros.h
@@ -65,6 +65,8 @@
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
+#elif defined(__GENODE__)
+ #define BENCHMARK_OS_GENODE 1
#endif
#if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \
diff --git a/llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn b/llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
index 1f07a6272d8..74eefe63b01 100644
--- a/llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
@@ -62,6 +62,7 @@ static_library("Driver") {
"ToolChains/DragonFly.cpp",
"ToolChains/FreeBSD.cpp",
"ToolChains/Fuchsia.cpp",
+ "ToolChains/Genode.cpp",
"ToolChains/Gnu.cpp",
"ToolChains/HIP.cpp",
"ToolChains/Haiku.cpp",

View File

@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ lib, stdenv, fetch, cmake, python, libcxxabi, fixDarwinDylibNames, version
, enableShared ? true }:
let
enableShared' = if enableShared then !stdenv.hostPlatform.isGenode else false;
in
stdenv.mkDerivation rec {
pname = "libc++";
inherit version;
src = fetch "libcxx" "0y4vc9z36c1zlq15cnibdzxnc1xi5glbc6klnm8a41q3db4541kz";
postUnpack = ''
unpackFile ${libcxxabi.src}
export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
'';
patches = with stdenv.hostPlatform; []
++ stdenv.lib.optional isMusl ../../libcxx-0001-musl-hacks.patch
++ stdenv.lib.optional isGenode ./genode.patch;
prePatch = ''
substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
'';
preConfigure = ''
# Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
patchShebangs utils/cat_files.py
'';
nativeBuildInputs = [ cmake ]
++ stdenv.lib.optional (with stdenv.hostPlatform; (isMusl || isWasi || isGenode)) python;
buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
cmakeFlags = [
"-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
"-DLIBCXX_LIBCPPABI_VERSION=2"
"-DLIBCXX_CXX_ABI=libcxxabi"
] ++ stdenv.lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1"
++ stdenv.lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON"
++ stdenv.lib.optional stdenv.hostPlatform.isGenode
"-DLIBCXX_ENABLE_THREADS=OFF"
++ stdenv.lib.optional stdenv.hostPlatform.isWasm [
"-DLIBCXX_ENABLE_THREADS=OFF"
"-DLIBCXX_ENABLE_FILESYSTEM=OFF"
"-DLIBCXX_ENABLE_EXCEPTIONS=OFF"
] ++ stdenv.lib.optional (!enableShared') "-DLIBCXX_ENABLE_SHARED=OFF";
enableParallelBuilding = true;
linkCxxAbi = stdenv.isLinux;
setupHooks = [
./role.bash
./setup-hook.sh
];
meta = {
homepage = http://libcxx.llvm.org/;
description = "A new implementation of the C++ standard library, targeting C++11";
license = with stdenv.lib.licenses; [ ncsa mit ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,74 @@
diff --git a/include/locale b/include/locale
index 2043892fa2d..6e5c285a7c9 100644
--- a/include/locale
+++ b/include/locale
@@ -737,7 +737,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
typename remove_reference<decltype(errno)>::type __save_errno = errno;
errno = 0;
char *__p2;
- long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+ long long __ll = strtoll(__a, &__p2, __base);
typename remove_reference<decltype(errno)>::type __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
@@ -777,7 +777,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
typename remove_reference<decltype(errno)>::type __save_errno = errno;
errno = 0;
char *__p2;
- unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+ unsigned long long __ll = strtoull(__a, &__p2, __base);
typename remove_reference<decltype(errno)>::type __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
@@ -806,19 +806,19 @@ _Tp __do_strtod(const char* __a, char** __p2);
template <>
inline _LIBCPP_INLINE_VISIBILITY
float __do_strtod<float>(const char* __a, char** __p2) {
- return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+ return strtof(__a, __p2);
}
template <>
inline _LIBCPP_INLINE_VISIBILITY
double __do_strtod<double>(const char* __a, char** __p2) {
- return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+ return strtod(__a, __p2);
}
template <>
inline _LIBCPP_INLINE_VISIBILITY
long double __do_strtod<long double>(const char* __a, char** __p2) {
- return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
+ return strtold(__a, __p2);
}
template <class _Tp>
@@ -1197,13 +1197,13 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
*__oe++ = __ct.widen(*__nf++);
*__oe++ = __ct.widen(*__nf++);
for (__ns = __nf; __ns < __ne; ++__ns)
- if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
+ if (!isxdigit(*__ns))
break;
}
else
{
for (__ns = __nf; __ns < __ne; ++__ns)
- if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
+ if (!isdigit(*__ns))
break;
}
if (__grouping.empty())
diff --git a/utils/google-benchmark/src/internal_macros.h b/utils/google-benchmark/src/internal_macros.h
index 5dbf4fd2752..4699c5ed913 100644
--- a/utils/google-benchmark/src/internal_macros.h
+++ b/utils/google-benchmark/src/internal_macros.h
@@ -70,6 +70,8 @@
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
+#elif defined(__GENODE__)
+ #define BENCHMARK_OS_GENODE 1
#endif
#if defined(__ANDROID__) && defined(__GLIBCXX__)

View File

@ -0,0 +1,75 @@
# Since the same derivation can be depend on in multiple ways, we need to
# accumulate *each* role (i.e. host and target platforms relative the depending
# derivation) in which the derivation is used.
#
# The role is intened to be use as part of other variables names like
# - $NIX_${role_pre}_SOMETHING
# - $NIX_SOMETHING_${role_post}
function getRole() {
case $1 in
-1)
role_pre='BUILD_'
role_post='_FOR_BUILD'
;;
0)
role_pre=''
role_post=''
;;
1)
role_pre='TARGET_'
role_post='_FOR_TARGET'
;;
*)
echo "@name@: used as improper sort of dependency" >2
return 1
;;
esac
}
# `hostOffset` describes how the host platform of the package is slid relative
# to the depending package. `targetOffset` likewise describes the target
# platform of the package. Both are brought into scope of the setup hook defined
# for dependency whose setup hook is being processed relative to the package
# being built.
function getHostRole() {
getRole "$hostOffset"
}
function getTargetRole() {
getRole "$targetOffset"
}
# `depHostOffset` describes how the host platform of the dependencies are slid
# relative to the depending package. `depTargetOffset` likewise describes the
# target platform of dependenices. Both are brought into scope of the
# environment hook defined for the dependency being applied relative to the
# package being built.
function getHostRoleEnvHook() {
getRole "$depHostOffset"
}
function getTargetRoleEnvHook() {
getRole "$depTargetOffset"
}
# This variant is inteneded specifically for code-prodocing tool wrapper scripts
# `NIX_@wrapperName@_@infixSalt@_TARGET_*` tracks this (needs to be an exported
# env var so can't use fancier data structures).
function getTargetRoleWrapper() {
case $targetOffset in
-1)
export NIX_@wrapperName@_@infixSalt@_TARGET_BUILD=1
;;
0)
export NIX_@wrapperName@_@infixSalt@_TARGET_HOST=1
;;
1)
export NIX_@wrapperName@_@infixSalt@_TARGET_TARGET=1
;;
*)
echo "@name@: used as improper sort of dependency" >2
return 1
;;
esac
}

View File

@ -0,0 +1,6 @@
# See pkgs/build-support/setup-hooks/role.bash
getHostRole
linkCxxAbi="@linkCxxAbi@"
export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
export NIX_${role_pre}CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View File

@ -0,0 +1,83 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? true }:
let
enableShared' = enableShared -> !stdenv.hostPlatform.isGenode;
in
stdenv.mkDerivation {
pname = "libc++abi";
inherit version;
src = fetch "libcxxabi" "1vznz8n1z1h8af0ga451m98lc2hjnv4fyzl71napsvjhvk4g6nxp";
nativeBuildInputs = [ cmake ];
buildInputs = stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isGenode && !stdenv.hostPlatform.isWasm) libunwind;
cmakeFlags = stdenv.lib.optionals (stdenv.hostPlatform.useLLVM or false) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
] ++ stdenv.lib.optionals stdenv.hostPlatform.isWasm [
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF"
] ++ stdenv.lib.optionals (!enableShared') [
"-DLIBCXXABI_ENABLE_SHARED=OFF"
] ++ stdenv.lib.optionals stdenv.hostPlatform.isGenode [
"-DCMAKE_C_FLAGS=-nodefaultlibs"
"-DLIBCXXABI_ENABLE_THREADS=OFF"
"-DLIBCXXABI_BAREMETAL=ON"
"-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON"
];
patches = [
./libcxxabi-no-threads.patch
];
postUnpack = ''
unpackFile ${libcxx.src}
unpackFile ${llvm.src}
cmakeFlags+=" -DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)"
'' + stdenv.lib.optionalString stdenv.isDarwin ''
export TRIPLE=x86_64-apple-darwin
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -d $(ls -d libcxx-*) -i ${../libcxx-0001-musl-hacks.patch}
'' + stdenv.lib.optionalString stdenv.targetPlatform.isGenode ''
patch -p1 -d $(ls -d llvm-*) -i ${./llvm-genode.patch}
'' + stdenv.lib.optionalString stdenv.hostPlatform.isWasm ''
patch -p1 -d $(ls -d llvm-*) -i ${./libcxxabi-wasm.patch}
'';
installPhase = if stdenv.isDarwin
then ''
for file in lib/*.dylib; do
# this should be done in CMake, but having trouble figuring out
# the magic combination of necessary CMake variables
# if you fancy a try, take a look at
# http://www.cmake.org/Wiki/CMake_RPATH_handling
install_name_tool -id $out/$file $file
done
make install
install -d 755 $out/include
install -m 644 ../include/*.h $out/include
''
else ''
install -d -m 755 $out/include $out/lib
install -m 644 lib/libc++abi.a $out/lib
install -m 644 ../include/*.h $out/include
'' + stdenv.lib.optionalString enableShared' ''
install -m 644 lib/libc++abi.so.1.0 $out/lib
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
'';
meta = {
homepage = http://libcxxabi.llvm.org/;
description = "A new implementation of low level support for a standard C++ library";
license = with stdenv.lib.licenses; [ ncsa mit ];
maintainers = with stdenv.lib.maintainers; [ vlstill ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4138acf..41b4763 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -362,6 +362,7 @@ if (NOT LIBCXXABI_ENABLE_THREADS)
" is also set to ON.")
endif()
add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
+ add_definitions(-D_LIBCPP_HAS_NO_THREADS)
endif()
if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)

View File

@ -0,0 +1,16 @@
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 15497d405e0..33f7f18193a 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -127,7 +127,10 @@ else(WIN32)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif()
else(FUCHSIA OR UNIX)
- MESSAGE(SEND_ERROR "Unable to determine platform")
+ if(${CMAKE_SYSTEM_NAME} MATCHES "Wasi")
+ else()
+ MESSAGE(SEND_ERROR "Unable to determine platform")
+ endif()
endif(FUCHSIA OR UNIX)
endif(WIN32)

View File

@ -0,0 +1,29 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d06073cfe7..076d8c383ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -333,6 +333,11 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
endif()
+if (LIBUNWIND_IS_BAREMETAL)
+ add_definitions(-D_LIBUNWIND_IS_BAREMETAL)
+ add_definitions(-D_LIBUNWIND_SUPPORT_DWARF_UNWIND)
+endif()
+
#===============================================================================
# Setup Source Code
#===============================================================================
diff --git a/src/assembly.h b/src/assembly.h
index 0b7d24389a4..84cb7bf2f8b 100644
--- a/src/assembly.h
+++ b/src/assembly.h
@@ -71,7 +71,7 @@
#define HIDDEN_SYMBOL(name) .hidden name
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
- defined(__linux__)
+ defined(__linux__) || defined(__GENODE__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE

View File

@ -0,0 +1,41 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv, version, fetch, cmake, fetchpatch
, enableShared ? true
, isBaremetal ? false }:
let
enableShared' = if stdenv.targetPlatform ? isGenode then
!stdenv.targetPlatform.isGenode
else
false;
in
stdenv.mkDerivation {
pname = "libunwind";
inherit version;
src = fetch "libunwind" "0vhgcgzsb33l83qaikrkj87ypqb48mi607rccczccwiiv8ficw0q";
nativeBuildInputs = [ cmake ];
patches = [
(fetchpatch {
url = "https://github.com/llvm-mirror/libunwind/commit/34a45c630d4c79af403661d267db42fbe7de1178.patch";
sha256 = "0n0pv6jvcky8pn3srhrf9x5kbnd0d2kia9xlx2g590f5q0bgwfhv";
})
(fetchpatch {
url = "https://github.com/llvm-mirror/libunwind/commit/e050272d2eb57eb4e56a37b429a61df2ebb8aa3e.patch";
sha256 = "1sxyx5xnax8k713jjcxgq3jq3cpnxygs2rcdf5vfja0f2k9jzldl";
})
] ++ stdenv.lib.optionals stdenv.hostPlatform.isGenode [
./libunwind-genode.patch
];
enableParallelBuilding = true;
cmakeFlags = [ ]
++ stdenv.lib.optional (!enableShared') "-DLIBUNWIND_ENABLE_SHARED=OFF"
++ stdenv.lib.optional isBaremetal "-DLIBUNWIND_IS_BAREMETAL=ON";
}

37
overlay/llvm-8/lld.nix Normal file
View File

@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv
, fetch
, cmake
, libxml2
, llvm
, version
}:
stdenv.mkDerivation {
pname = "lld";
inherit version;
src = fetch "lld" "121xhxrlvwy3k5nf6p1wv31whxlb635ssfkci8z93mwv4ja1xflz";
nativeBuildInputs = [ cmake ];
buildInputs = [ llvm libxml2 ];
outputs = [ "out" "dev" ];
enableParallelBuilding = true;
postInstall = ''
moveToOutput include "$dev"
moveToOutput lib "$dev"
'';
meta = {
description = "The LLVM Linker";
homepage = http://lld.llvm.org/;
license = stdenv.lib.licenses.ncsa;
platforms = stdenv.lib.platforms.all;
};
}

65
overlay/llvm-8/lldb.nix Normal file
View File

@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv
, fetch
, cmake
, zlib
, ncurses
, swig
, which
, libedit
, libxml2
, llvm
, clang-unwrapped
, python
, version
, darwin
}:
stdenv.mkDerivation {
pname = "lldb";
inherit version;
src = fetch "lldb" "1mriw4adrwm6kzabrjr7yqmdiylxd6glf6samd80dp8idnm9p9z8";
postPatch = ''
# Fix up various paths that assume llvm and clang are installed in the same place
sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \
cmake/modules/LLDBStandalone.cmake
sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \
cmake/modules/LLDBStandalone.cmake
sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \
cmake/modules/LLDBStandalone.cmake
'';
nativeBuildInputs = [ cmake python which swig ];
buildInputs = [ ncurses zlib libedit libxml2 llvm ]
++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc darwin.apple_sdk.frameworks.Foundation darwin.bootstrap_cmds darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa ];
CXXFLAGS = "-fno-rtti";
hardeningDisable = [ "format" ];
cmakeFlags = [
"-DLLDB_CODESIGN_IDENTITY=" # codesigning makes nondeterministic
];
enableParallelBuilding = true;
postInstall = ''
mkdir -p $out/share/man/man1
cp ../docs/lldb.1 $out/share/man/man1/
install -D ../tools/lldb-vscode/package.json $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/package.json
mkdir $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
ln -s $out/bin/lldb-vscode $out/share/vscode/extensions/llvm-org.lldb-vscode-0.1.0/bin
'';
meta = with stdenv.lib; {
description = "A next-generation high-performance debugger";
homepage = http://llvm.org/;
license = licenses.ncsa;
platforms = platforms.all;
};
}

View File

@ -0,0 +1,157 @@
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 49db3088bbc..32ffed3cb2e 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -107,7 +107,7 @@ if(WIN32)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
else(WIN32)
- if(FUCHSIA OR UNIX)
+ if(FUCHSIA OR GENODE OR UNIX)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
@@ -115,9 +115,9 @@ else(WIN32)
else()
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif()
- else(FUCHSIA OR UNIX)
+ else(FUCHSIA OR GENODE OR UNIX)
MESSAGE(SEND_ERROR "Unable to determine platform")
- endif(FUCHSIA OR UNIX)
+ endif(FUCHSIA OR GENODE OR UNIX)
endif(WIN32)
set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index e06a68e2731..7da3d5d29bc 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -159,6 +159,7 @@ public:
DragonFly,
FreeBSD,
Fuchsia,
+ Genode,
IOS,
KFreeBSD,
Linux,
@@ -498,6 +499,8 @@ public:
bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
+ bool isOSGenode() const { return getOS() == Triple::Genode; }
+
bool isOSSolaris() const {
return getOS() == Triple::Solaris;
}
diff --git a/include/llvm/BinaryFormat/ELF.h b/include/llvm/BinaryFormat/ELF.h
index ce35d127d43..d7a589057db 100644
--- a/include/llvm/BinaryFormat/ELF.h
+++ b/include/llvm/BinaryFormat/ELF.h
@@ -348,6 +348,7 @@ enum {
ELFOSABI_AROS = 15, // AROS
ELFOSABI_FENIXOS = 16, // FenixOS
ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
+ ELFOSABI_GENODE = 18, // Genode
ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h
index f226d6a45a5..91efe079d20 100644
--- a/include/llvm/MC/MCELFObjectWriter.h
+++ b/include/llvm/MC/MCELFObjectWriter.h
@@ -74,6 +74,8 @@ public:
switch (OSType) {
case Triple::CloudABI:
return ELF::ELFOSABI_CLOUDABI;
+ case Triple::Genode:
+ return ELF::ELFOSABI_GENODE;
case Triple::HermitCore:
return ELF::ELFOSABI_STANDALONE;
case Triple::PS4:
diff --git a/lib/ObjectYAML/ELFYAML.cpp b/lib/ObjectYAML/ELFYAML.cpp
index 215d6bdd091..0d3f5eaf032 100644
--- a/lib/ObjectYAML/ELFYAML.cpp
+++ b/lib/ObjectYAML/ELFYAML.cpp
@@ -260,6 +260,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
ECase(ELFOSABI_AROS);
ECase(ELFOSABI_FENIXOS);
ECase(ELFOSABI_CLOUDABI);
+ ECase(ELFOSABI_GENODE);
ECase(ELFOSABI_AMDGPU_HSA);
ECase(ELFOSABI_AMDGPU_PAL);
ECase(ELFOSABI_AMDGPU_MESA3D);
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
index 26d9327f620..1866b07ac68 100644
--- a/lib/Support/Triple.cpp
+++ b/lib/Support/Triple.cpp
@@ -181,6 +181,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
case DragonFly: return "dragonfly";
case FreeBSD: return "freebsd";
case Fuchsia: return "fuchsia";
+ case Genode: return "genode";
case IOS: return "ios";
case KFreeBSD: return "kfreebsd";
case Linux: return "linux";
@@ -478,6 +479,7 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("dragonfly", Triple::DragonFly)
.StartsWith("freebsd", Triple::FreeBSD)
.StartsWith("fuchsia", Triple::Fuchsia)
+ .StartsWith("genode", Triple::Genode)
.StartsWith("ios", Triple::IOS)
.StartsWith("kfreebsd", Triple::KFreeBSD)
.StartsWith("linux", Triple::Linux)
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
index 93254717e92..3d96ff9332a 100644
--- a/tools/llvm-readobj/ELFDumper.cpp
+++ b/tools/llvm-readobj/ELFDumper.cpp
@@ -911,6 +911,7 @@ static const EnumEntry<unsigned> ElfOSABI[] = {
{"AROS", "AROS", ELF::ELFOSABI_AROS},
{"FenixOS", "FenixOS", ELF::ELFOSABI_FENIXOS},
{"CloudABI", "CloudABI", ELF::ELFOSABI_CLOUDABI},
+ {"Genode", "Genode", ELF::ELFOSABI_GENODE},
{"Standalone", "Standalone App", ELF::ELFOSABI_STANDALONE}
};
diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp
index bc7f9321caa..5d6a56d7723 100644
--- a/unittests/ADT/TripleTest.cpp
+++ b/unittests/ADT/TripleTest.cpp
@@ -241,6 +241,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Fuchsia, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+ T = Triple("x86_64-unknown-genode");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::Genode, T.getOS());
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
T = Triple("x86_64-unknown-hermit");
EXPECT_EQ(Triple::x86_64, T.getArch());
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
diff --git a/utils/benchmark/src/internal_macros.h b/utils/benchmark/src/internal_macros.h
index f2d54bfcbd9..e20f891d435 100644
--- a/utils/benchmark/src/internal_macros.h
+++ b/utils/benchmark/src/internal_macros.h
@@ -65,6 +65,8 @@
#define BENCHMARK_OS_FUCHSIA 1
#elif defined (__SVR4) && defined (__sun)
#define BENCHMARK_OS_SOLARIS 1
+#elif defined(__GENODE__)
+ #define BENCHMARK_OS_GENODE 1
#endif
#if !__has_feature(cxx_exceptions) && !defined(__cpp_exceptions) \
diff --git a/utils/gn/secondary/clang/lib/Driver/BUILD.gn b/utils/gn/secondary/clang/lib/Driver/BUILD.gn
index 1f07a6272d8..74eefe63b01 100644
--- a/utils/gn/secondary/clang/lib/Driver/BUILD.gn
+++ b/utils/gn/secondary/clang/lib/Driver/BUILD.gn
@@ -62,6 +62,7 @@ static_library("Driver") {
"ToolChains/DragonFly.cpp",
"ToolChains/FreeBSD.cpp",
"ToolChains/Fuchsia.cpp",
+ "ToolChains/Genode.cpp",
"ToolChains/Gnu.cpp",
"ToolChains/HIP.cpp",
"ToolChains/Haiku.cpp",

View File

@ -0,0 +1,26 @@
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 94d426b..37f7794 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
ActiveIncludeOption = "-I" + ActiveIncludeDir;
}
+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
+ if (!IsInDevelopmentTree) {
+ bool WantShared = true;
+ for (int i = 1; i < argc; ++i) {
+ StringRef Arg = argv[i];
+ if (Arg == "--link-shared")
+ WantShared = true;
+ else if (Arg == "--link-static")
+ WantShared = false; // the last one wins
+ }
+
+ if (WantShared)
+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
+ }
+
/// We only use `shared library` mode in cases where the static library form
/// of the components provided are not available; note however that this is
/// skipped if we're run from within the build dir. However, once installed,

179
overlay/llvm-8/llvm.nix Normal file
View File

@ -0,0 +1,179 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv
, fetch
, cmake
, python
, libffi
, libbfd
, libpfm
, libxml2
, ncurses
, version
, release_version
, zlib
, buildPackages
, debugVersion ? false
, enableManpages ? false
, enableSharedLibraries ? true
, enablePFM ? !(stdenv.isDarwin
|| stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
)
, enablePolly ? false
}:
let
inherit (stdenv.lib) optional optionals optionalString;
# Used when creating a version-suffixed symlink of libLLVM.dylib
shortVersion = with stdenv.lib;
concatStringsSep "." (take 1 (splitString "." release_version));
in stdenv.mkDerivation ({
name = "llvm-${version}";
src = fetch "llvm" "1rvm5gqp5v8hfn17kqws3zhk94w4kxndal12bqa0y57p09nply24";
polly_src = fetch "polly" "1lfjdz3ilj5xmjxvicd8f5ykybks67ry2pdb777352r3mzlgg8g8";
unpackPhase = ''
unpackFile $src
mv llvm-${version}* llvm
sourceRoot=$PWD/llvm
'' + optionalString enablePolly ''
unpackFile $polly_src
mv polly-* $sourceRoot/tools/polly
'';
outputs = [ "out" "python" ]
++ optional enableSharedLibraries "lib";
nativeBuildInputs = [ cmake python ]
++ optionals enableManpages [ python.pkgs.sphinx python.pkgs.recommonmark ];
buildInputs = [ libxml2 libffi ]
++ optional enablePFM libpfm; # exegesis
propagatedBuildInputs = [ ncurses zlib ];
patches = [ ./llvm-genode.patch ];
postPatch = optionalString stdenv.isDarwin ''
substituteInPlace cmake/modules/AddLLVM.cmake \
--replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir)" \
--replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' ""
''
# Patch llvm-config to return correct library path based on --link-{shared,static}.
+ optionalString (enableSharedLibraries) ''
substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib
patch -p1 < ./llvm-outputs.patch
'' + ''
# FileSystem permissions tests fail with various special bits
substituteInPlace unittests/Support/CMakeLists.txt \
--replace "Path.cpp" ""
rm unittests/Support/Path.cpp
'' + optionalString stdenv.hostPlatform.isMusl ''
patch -p1 -i ${../TLI-musl.patch}
substituteInPlace unittests/Support/CMakeLists.txt \
--replace "add_subdirectory(DynamicLibrary)" ""
rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
# valgrind unhappy with musl or glibc, but fails w/musl only
rm test/CodeGen/AArch64/wineh4.mir
'' + ''
patchShebangs test/BugPoint/compile-custom.ll.py
'';
# hacky fix: created binaries need to be run before installation
preBuild = ''
mkdir -p $out/
ln -sv $PWD/lib $out
'';
cmakeFlags = with stdenv; [
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
"-DLLVM_BUILD_TESTS=ON"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_ENABLE_DUMP=ON"
] ++ optionals enableSharedLibraries [
"-DLLVM_LINK_LLVM_DYLIB=ON"
] ++ optionals enableManpages [
"-DLLVM_BUILD_DOCS=ON"
"-DLLVM_ENABLE_SPHINX=ON"
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ++ optionals (!isDarwin) [
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
] ++ optionals (isDarwin) [
"-DLLVM_ENABLE_LIBCXX=ON"
"-DCAN_TARGET_i386=false"
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DCMAKE_CROSSCOMPILING=True"
"-DLLVM_TABLEGEN=${buildPackages.llvm_7}/bin/llvm-tblgen"
];
postBuild = ''
rm -fR $out
'';
preCheck = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
'';
postInstall = ''
mkdir -p $python/share
mv $out/share/opt-viewer $python/share/opt-viewer
''
+ optionalString enableSharedLibraries ''
moveToOutput "lib/libLLVM-*" "$lib"
moveToOutput "lib/libLLVM${stdenv.hostPlatform.extensions.sharedLibrary}" "$lib"
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-"
''
+ optionalString (stdenv.isDarwin && enableSharedLibraries) ''
substituteInPlace "$out/lib/cmake/llvm/LLVMExports-${if debugVersion then "debug" else "release"}.cmake" \
--replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib"
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib
ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib
'';
doCheck = stdenv.isLinux && (!stdenv.isx86_32);
checkTarget = "check-all";
enableParallelBuilding = true;
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.ncsa;
maintainers = with stdenv.lib.maintainers; [ lovek323 raskin dtzWill ];
platforms = stdenv.lib.platforms.all;
};
} // stdenv.lib.optionalAttrs enableManpages {
name = "llvm-manpages-${version}";
buildPhase = ''
make docs-llvm-man
'';
propagatedBuildInputs = [];
installPhase = ''
make -C docs install
'';
postPatch = null;
postInstall = null;
outputs = [ "out" ];
doCheck = false;
meta.description = "man pages for LLVM ${version}";
})

30
overlay/llvm-8/openmp.nix Normal file
View File

@ -0,0 +1,30 @@
# SPDX-FileCopyrightText: 2003-2020 Nixpkgs/NixOS contributors
#
# SPDX-License-Identifier: MIT
{ stdenv
, fetch
, cmake
, llvm
, perl
, version
}:
stdenv.mkDerivation {
pname = "openmp";
inherit version;
src = fetch "openmp" "0b3jlxhqbpyd1nqkpxjfggm5d9va5qpyf7d4i5y7n4a1mlydv19y";
nativeBuildInputs = [ cmake perl ];
buildInputs = [ llvm ];
enableParallelBuilding = true;
meta = {
description = "Components required to build an executable OpenMP program";
homepage = http://openmp.llvm.org/;
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,412 @@
From f7a253f8f85d0f49df6b73996737a3e84ac64236 Mon Sep 17 00:00:00 2001
From: Will Dietz <w@wdtz.org>
Date: Mon, 24 Sep 2018 11:17:25 -0500
Subject: [PATCH] Ported to 7.0, taken from gentoo-musl project.
------
Ported to compiler-rt-sanitizers-5.0.0. Taken from
https://gist.githubusercontent.com/pwaller/2337f3290f12634cad3e3730cff0a6c1/raw/83c87a8585e2f9662494db5662e5361beb093c26/nongnu.patch
Signed-off-by: Jory A. Pratt <anarchy@gentoo.org>
Taken from gentoo-musl project, with a few additional minor fixes.
---
lib/asan/asan_linux.cc | 4 +-
lib/interception/interception_linux.cc | 2 +-
lib/interception/interception_linux.h | 2 +-
lib/msan/msan_linux.cc | 2 +-
lib/sanitizer_common/sanitizer_allocator.cc | 2 +-
.../sanitizer_common_interceptors_ioctl.inc | 4 +-
.../sanitizer_common_syscalls.inc | 2 +-
lib/sanitizer_common/sanitizer_linux.cc | 8 +++-
.../sanitizer_linux_libcdep.cc | 10 ++---
lib/sanitizer_common/sanitizer_platform.h | 6 +++
.../sanitizer_platform_interceptors.h | 4 +-
.../sanitizer_platform_limits_posix.cc | 37 +++++++++++--------
lib/tsan/rtl/tsan_platform_linux.cc | 2 +-
13 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index 625f32d40..73cf77aca 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -46,7 +46,7 @@
#include <link.h>
#endif
-#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
+#if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
#include <ucontext.h>
extern "C" void* _DYNAMIC;
#elif SANITIZER_NETBSD
@@ -139,7 +139,7 @@ void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
UNIMPLEMENTED();
}
-#if SANITIZER_ANDROID
+#if SANITIZER_ANDROID || SANITIZER_NONGNU
// FIXME: should we do anything for Android?
void AsanCheckDynamicRTPrereqs() {}
void AsanCheckIncompatibleRT() {}
diff --git a/lib/interception/interception_linux.cc b/lib/interception/interception_linux.cc
index 26bfcd8f6..529b234f7 100644
--- a/lib/interception/interception_linux.cc
+++ b/lib/interception/interception_linux.cc
@@ -43,7 +43,7 @@ bool GetRealFunctionAddress(const char *func_name, uptr *func_addr,
}
// Android and Solaris do not have dlvsym
-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
+#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
void *GetFuncAddrVer(const char *func_name, const char *ver) {
return dlvsym(RTLD_NEXT, func_name, ver);
}
diff --git a/lib/interception/interception_linux.h b/lib/interception/interception_linux.h
index 942c25609..24a4d5080 100644
--- a/lib/interception/interception_linux.h
+++ b/lib/interception/interception_linux.h
@@ -36,7 +36,7 @@ void *GetFuncAddrVer(const char *func_name, const char *ver);
(::__interception::uptr) & WRAP(func))
// Android, Solaris and OpenBSD do not have dlvsym
-#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD
+#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
(::__interception::real_##func = (func##_f)( \
unsigned long)::__interception::GetFuncAddrVer(#func, symver))
diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
index 385a650c4..6e30a8ce9 100644
--- a/lib/msan/msan_linux.cc
+++ b/lib/msan/msan_linux.cc
@@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#include "sanitizer_common/sanitizer_platform.h"
-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
+#if SANITIZER_FREEBSD || (SANITIZER_LINUX && !SANITIZER_NONGNU) || SANITIZER_NETBSD
#include "msan.h"
#include "msan_report.h"
diff --git a/lib/sanitizer_common/sanitizer_allocator.cc b/lib/sanitizer_common/sanitizer_allocator.cc
index 6bfd5e5ee..048f6154f 100644
--- a/lib/sanitizer_common/sanitizer_allocator.cc
+++ b/lib/sanitizer_common/sanitizer_allocator.cc
@@ -27,7 +27,7 @@ const char *SecondaryAllocatorName = "LargeMmapAllocator";
// ThreadSanitizer for Go uses libc malloc/free.
#if SANITIZER_GO || defined(SANITIZER_USE_MALLOC)
-# if SANITIZER_LINUX && !SANITIZER_ANDROID
+# if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
extern "C" void *__libc_malloc(uptr size);
# if !SANITIZER_GO
extern "C" void *__libc_memalign(uptr alignment, uptr size);
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
index 2d633c173..b6eb23116 100644
--- a/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc
@@ -104,7 +104,7 @@ static void ioctl_table_fill() {
_(SIOCGETVIFCNT, WRITE, struct_sioc_vif_req_sz);
#endif
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX && !SANITIZER_NONGNU
// Conflicting request ids.
// _(CDROMAUDIOBUFSIZ, NONE, 0);
// _(SNDCTL_TMR_CONTINUE, NONE, 0);
@@ -365,7 +365,7 @@ static void ioctl_table_fill() {
_(VT_WAITACTIVE, NONE, 0);
#endif
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
// _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE
_(CYGETDEFTHRESH, WRITE, sizeof(int));
_(CYGETDEFTIMEOUT, WRITE, sizeof(int));
diff --git a/lib/sanitizer_common/sanitizer_common_syscalls.inc b/lib/sanitizer_common/sanitizer_common_syscalls.inc
index 469c8eb7e..24f87867d 100644
--- a/lib/sanitizer_common/sanitizer_common_syscalls.inc
+++ b/lib/sanitizer_common/sanitizer_common_syscalls.inc
@@ -2038,7 +2038,7 @@ POST_SYSCALL(setrlimit)(long res, long resource, void *rlim) {
}
}
-#if !SANITIZER_ANDROID
+#if !SANITIZER_ANDROID && !SANITIZER_NONGNU
PRE_SYSCALL(prlimit64)(long pid, long resource, const void *new_rlim,
void *old_rlim) {
if (new_rlim) PRE_READ(new_rlim, struct_rlimit64_sz);
diff --git a/lib/sanitizer_common/sanitizer_linux.cc b/lib/sanitizer_common/sanitizer_linux.cc
index 96d6c1eff..9e2b7fb9d 100644
--- a/lib/sanitizer_common/sanitizer_linux.cc
+++ b/lib/sanitizer_common/sanitizer_linux.cc
@@ -541,13 +541,13 @@ const char *GetEnv(const char *name) {
#endif
}
-#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD
+#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_NONGNU
extern "C" {
SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end;
}
#endif
-#if !SANITIZER_GO && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \
+#if (!SANITIZER_GO || SANITIZER_NONGNU) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD && \
!SANITIZER_OPENBSD
static void ReadNullSepFileToArray(const char *path, char ***arr,
int arr_size) {
@@ -590,6 +590,10 @@ static void GetArgsAndEnv(char ***argv, char ***envp) {
#elif SANITIZER_NETBSD
*argv = __ps_strings->ps_argvstr;
*envp = __ps_strings->ps_envstr;
+#elif SANITIZER_NONGNU
+ static const int kMaxArgv = 2000, kMaxEnvp = 2000;
+ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv);
+ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp);
#else // SANITIZER_FREEBSD
#if !SANITIZER_GO
if (&__libc_stack_end) {
diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
index 4962ff832..438f94dbe 100644
--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -179,7 +179,7 @@ __attribute__((unused)) static bool GetLibcVersion(int *major, int *minor,
}
#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \
- !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS
+ !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS && !SANITIZER_NONGNU
static uptr g_tls_size;
#ifdef __i386__
@@ -261,7 +261,7 @@ void InitTlsSize() { }
#if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) || \
defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) || \
defined(__arm__)) && \
- SANITIZER_LINUX && !SANITIZER_ANDROID
+ SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
// sizeof(struct pthread) from glibc.
static atomic_uintptr_t thread_descriptor_size;
@@ -426,7 +426,7 @@ int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
#if !SANITIZER_GO
static void GetTls(uptr *addr, uptr *size) {
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
# if defined(__x86_64__) || defined(__i386__) || defined(__s390__)
*addr = ThreadSelf();
*size = GetTlsSize();
@@ -470,7 +470,7 @@ static void GetTls(uptr *addr, uptr *size) {
#elif SANITIZER_OPENBSD
*addr = 0;
*size = 0;
-#elif SANITIZER_ANDROID
+#elif SANITIZER_ANDROID || SANITIZER_NONGNU
*addr = 0;
*size = 0;
#elif SANITIZER_SOLARIS
@@ -486,7 +486,7 @@ static void GetTls(uptr *addr, uptr *size) {
#if !SANITIZER_GO
uptr GetTlsSize() {
#if SANITIZER_FREEBSD || SANITIZER_ANDROID || SANITIZER_NETBSD || \
- SANITIZER_OPENBSD || SANITIZER_SOLARIS
+ SANITIZER_OPENBSD || SANITIZER_SOLARIS || SANITIZER_NONGNU
uptr addr, size;
GetTls(&addr, &size);
return size;
diff --git a/lib/sanitizer_common/sanitizer_platform.h b/lib/sanitizer_common/sanitizer_platform.h
index d81e25580..e10680ac8 100644
--- a/lib/sanitizer_common/sanitizer_platform.h
+++ b/lib/sanitizer_common/sanitizer_platform.h
@@ -208,6 +208,12 @@
# define SANITIZER_SOLARIS32 0
#endif
+#if defined(__linux__) && !defined(__GLIBC__)
+# define SANITIZER_NONGNU 1
+#else
+# define SANITIZER_NONGNU 0
+#endif
+
#if defined(__myriad2__)
# define SANITIZER_MYRIAD2 1
#else
diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
index f95539a73..6c53b3415 100644
--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -39,7 +39,7 @@
# include "sanitizer_platform_limits_solaris.h"
#endif
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
# define SI_LINUX_NOT_ANDROID 1
#else
# define SI_LINUX_NOT_ANDROID 0
@@ -322,7 +322,7 @@
#define SANITIZER_INTERCEPT_ETHER_R (SI_FREEBSD || SI_LINUX_NOT_ANDROID)
#define SANITIZER_INTERCEPT_SHMCTL \
(SI_NETBSD || SI_OPENBSD || SI_SOLARIS || \
- ((SI_FREEBSD || SI_LINUX_NOT_ANDROID) && \
+ ((SI_FREEBSD || SI_LINUX_NOT_ANDROID || SANITIZER_NONGNU) && \
SANITIZER_WORDSIZE == 64)) // NOLINT
#define SANITIZER_INTERCEPT_RANDOM_R SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_PTHREAD_ATTR_GET SI_POSIX
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
index 54da635d7..2f6ff69c3 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -14,6 +14,9 @@
#include "sanitizer_platform.h"
+// Workaround musl <--> linux conflicting definition of 'struct sysinfo'
+#define _LINUX_SYSINFO_H
+
#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
// Tests in this file assume that off_t-dependent data structures match the
// libc ABI. For example, struct dirent here is what readdir() function (as
@@ -138,12 +141,14 @@ typedef struct user_fpregs elf_fpregset_t;
#if SANITIZER_LINUX && !SANITIZER_ANDROID
#include <glob.h>
-#include <obstack.h>
+# if !SANITIZER_NONGNU
+# include <obstack.h>
+# endif
#include <mqueue.h>
-#include <net/if_ppp.h>
-#include <netax25/ax25.h>
-#include <netipx/ipx.h>
-#include <netrom/netrom.h>
+#include <linux/if_ppp.h>
+#include <linux/ax25.h>
+#include <linux/ipx.h>
+#include <linux/netrom.h>
#if HAVE_RPC_XDR_H
# include <rpc/xdr.h>
#elif HAVE_TIRPC_RPC_XDR_H
@@ -251,7 +256,7 @@ namespace __sanitizer {
unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
// Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
// has been removed from glibc 2.28.
#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
@@ -322,7 +327,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(ElfW(Phdr));
unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
#endif
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
int glob_nomatch = GLOB_NOMATCH;
int glob_altdirfunc = GLOB_ALTDIRFUNC;
#endif
@@ -416,7 +421,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
unsigned struct_termios_sz = sizeof(struct termios);
unsigned struct_winsize_sz = sizeof(struct winsize);
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX && !SANITIZER_NONGNU
unsigned struct_arpreq_sz = sizeof(struct arpreq);
unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
@@ -466,7 +471,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
#if EV_VERSION > (0x010000)
@@ -834,7 +839,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
unsigned IOCTL_CYGETMON = CYGETMON;
@@ -989,7 +994,7 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
CHECK_TYPE_SIZE(glob_t);
CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
@@ -1023,6 +1028,7 @@ CHECK_TYPE_SIZE(iovec);
CHECK_SIZE_AND_OFFSET(iovec, iov_base);
CHECK_SIZE_AND_OFFSET(iovec, iov_len);
+#if !SANITIZER_NONGNU
CHECK_TYPE_SIZE(msghdr);
CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
@@ -1036,6 +1042,7 @@ CHECK_TYPE_SIZE(cmsghdr);
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
+#endif
#ifndef __GLIBC_PREREQ
#define __GLIBC_PREREQ(x, y) 0
@@ -1145,7 +1152,7 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
CHECK_TYPE_SIZE(ether_addr);
-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
+#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID && !SANITIZER_NONGNU
CHECK_TYPE_SIZE(ipc_perm);
# if SANITIZER_FREEBSD
CHECK_SIZE_AND_OFFSET(ipc_perm, key);
@@ -1206,7 +1213,7 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
#endif
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX && !SANITIZER_NONGNU
COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
#endif
@@ -1256,7 +1263,7 @@ COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
#endif
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
CHECK_SIZE_AND_OFFSET(FILE, _flags);
CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
@@ -1275,7 +1282,7 @@ CHECK_SIZE_AND_OFFSET(FILE, _chain);
CHECK_SIZE_AND_OFFSET(FILE, _fileno);
#endif
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc
index de989b780..51a97b554 100644
--- a/lib/tsan/rtl/tsan_platform_linux.cc
+++ b/lib/tsan/rtl/tsan_platform_linux.cc
@@ -294,7 +294,7 @@ void InitializePlatform() {
// This is required to properly "close" the fds, because we do not see internal
// closes within glibc. The code is a pure hack.
int ExtractResolvFDs(void *state, int *fds, int nfd) {
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
+#if SANITIZER_LINUX && !SANITIZER_ANDROID && !SANITIZER_NONGNU
int cnt = 0;
struct __res_state *statp = (struct __res_state*)state;
for (int i = 0; i < MAXNS && cnt < nfd; i++) {
--
2.19.0

View File

@ -12,7 +12,7 @@ let
addManifest = drv: { manifest = mkDhallManifest drv; } // drv; addManifest = drv: { manifest = mkDhallManifest drv; } // drv;
callPackage' = path: attrs: callPackage' = path: attrs:
addManifest (legacyPackages.callPackages path attrs); addManifest (legacyPackages.callPackage path attrs);
genodeLabs = import ./genodelabs { genodeLabs = import ./genodelabs {
nixpkgs = legacyPackages; nixpkgs = legacyPackages;