From 3ad62e086e87ed24d9f178145d70a362247bd180 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 30 Jul 2019 12:48:01 +0200 Subject: [PATCH] Initial commit --- .gitignore | 2 + default.nix | 43 + ports/default.nix | 24 + ports/egl_api/default.nix | 27 + ports/egl_api/egl_api.pc.in | 6 + ports/libc/default.nix | 52 ++ ports/libc/libc-builder.sh | 255 ++++++ ports/libc/libc.pc.in | 8 + ports/libc/libc.symbols | 1057 +++++++++++++++++++++ ports/libc/posix.pc.in | 5 + ports/libm/default.nix | 31 + ports/libm/libm.pc.in | 6 + ports/libm/libm.symbols | 322 +++++++ ports/mesa/default.nix | 63 ++ ports/mesa/mesa.pc.in | 7 + ports/stdcxx/default.nix | 102 +++ ports/stdcxx/stdcxx.pc.in | 7 + ports/stdcxx/stdcxx.symbols | 864 ++++++++++++++++++ ports/zlib/default.nix | 23 + release.nix | 16 + shell.nix | 37 + tool/default.nix | 477 ++++++++++ tool/prepare-port/builder.sh | 12 + tool/prepare-port/default-builder.sh | 2 + tool/prepare-port/default.nix | 42 + tool/prepare-port/genode_rel.ld | 261 ++++++ tool/prepare-port/setup.sh | 1264 ++++++++++++++++++++++++++ tool/setup-hooks.sh | 7 + tool/toolchain.nix | 69 ++ upstream/default.nix | 73 ++ 30 files changed, 5164 insertions(+) create mode 100644 .gitignore create mode 100644 default.nix create mode 100644 ports/default.nix create mode 100644 ports/egl_api/default.nix create mode 100644 ports/egl_api/egl_api.pc.in create mode 100644 ports/libc/default.nix create mode 100755 ports/libc/libc-builder.sh create mode 100644 ports/libc/libc.pc.in create mode 100644 ports/libc/libc.symbols create mode 100644 ports/libc/posix.pc.in create mode 100644 ports/libm/default.nix create mode 100644 ports/libm/libm.pc.in create mode 100644 ports/libm/libm.symbols create mode 100644 ports/mesa/default.nix create mode 100644 ports/mesa/mesa.pc.in create mode 100644 ports/stdcxx/default.nix create mode 100644 ports/stdcxx/stdcxx.pc.in create mode 100644 ports/stdcxx/stdcxx.symbols create mode 100644 ports/zlib/default.nix create mode 100644 release.nix create mode 100644 shell.nix create mode 100644 tool/default.nix create mode 100644 tool/prepare-port/builder.sh create mode 100644 tool/prepare-port/default-builder.sh create mode 100644 tool/prepare-port/default.nix create mode 100644 tool/prepare-port/genode_rel.ld create mode 100644 tool/prepare-port/setup.sh create mode 100644 tool/setup-hooks.sh create mode 100644 tool/toolchain.nix create mode 100644 upstream/default.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..750baeb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +result-* diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..12e488e --- /dev/null +++ b/default.nix @@ -0,0 +1,43 @@ +{ nixpkgs ? import +, system ? { config = "x86_64-unknown-genode"; } +}: + +with builtins; + +let + nixpkgs' = nixpkgs + { crossSystem = system; + config.allowUnsupportedSystem = true; + }; + + portIncludes = ports: listToAttrs + ( map + ( name: + let port = getAttr name ports; in + { name = name + "_include"; + value = getAttr "include" port; + } + ) + (attrNames ports) + ); + + toolchain = import ./tool/toolchain.nix; +in +rec { + inherit toolchain; + nixpkgs = nixpkgs'; + + dhall = import ./dhall { inherit nixpkgs; }; + + upstream = import ./upstream { inherit nixpkgs toolchain; }; + + ports = import ./ports { inherit nixpkgs toolchain upstream; }; + + libretro = import ./libretro { inherit nixpkgs upstream toolchain; inherit (ports) stdcxx libc; }; + + shell = import ./shell.nix + { inherit nixpkgs toolchain; + dhallPackages = dhall; + pkgs = { inherit upstream ports; }; + }; +} diff --git a/ports/default.nix b/ports/default.nix new file mode 100644 index 0000000..09084df --- /dev/null +++ b/ports/default.nix @@ -0,0 +1,24 @@ +{ nixpkgs, ... } @ args: + +let + tool = import ./../tool { inherit nixpkgs; }; + importPort = path: + let f = (import path); + in f (builtins.intersectAttrs (builtins.functionArgs f) (tool // args)); + + hasSuffixNix = tool.hasSuffix ".nix"; +in +builtins.listToAttrs ( + builtins.filter + (x: x != null) + (map + (fn: + if fn != "default.nix" then + { name = tool.replaceInString ".nix" "" fn; + value = importPort (../ports + "/${fn}"); + } + else null + ) + (builtins.attrNames (builtins.readDir ../ports)) + ) +) diff --git a/ports/egl_api/default.nix b/ports/egl_api/default.nix new file mode 100644 index 0000000..5eff861 --- /dev/null +++ b/ports/egl_api/default.nix @@ -0,0 +1,27 @@ +{ preparePort, nixpkgs, upstream }: + +let + inherit (nixpkgs) fetchFromGitHub fetchgit; + upstreamSrc = import ./../../upstream/src.nix { inherit fetchgit; }; +in +preparePort { + name = "egl"; + outputs = [ "dev" ]; + + src = fetchFromGitHub { + name = "EGL"; + owner = "KhronosGroup"; + repo = "EGL-Registry"; + rev = "d738c39fe25bab9f65bed2cb78c4db253bd473c4"; + sha256 = "1bb2pgv516i1p8x3171yj3gqkxqxqwg7q42ak627md4x3irmqf2q"; + }; + + installPhase = '' + mkdir -p $includedir $pkgconfigdir + + substituteAll ${./egl_api.pc.in} $pkgconfigdir/egl_api.pc + + cp -r api/1.? api/EGL api/KHR $includedir + cp ${upstream.src}/repos/libports/include/EGL/eglplatform.h $includedir/EGL/eglplatform.h + ''; +} diff --git a/ports/egl_api/egl_api.pc.in b/ports/egl_api/egl_api.pc.in new file mode 100644 index 0000000..1ebede6 --- /dev/null +++ b/ports/egl_api/egl_api.pc.in @@ -0,0 +1,6 @@ +includedir=@includedir@ + +Name: EGL +Description: EGL API headers +Version: @version@ +Cflags: -I${includedir} diff --git a/ports/libc/default.nix b/ports/libc/default.nix new file mode 100644 index 0000000..396a5c6 --- /dev/null +++ b/ports/libc/default.nix @@ -0,0 +1,52 @@ +{ preparePort, nixpkgs, toolchain, upstream }: + +let + inherit (nixpkgs.buildPackages) fetchurl ; +in +preparePort { + name = "libc-freebsd-12.0.0"; + outputs = [ "source" "dev" ]; + + builder = ./libc-builder.sh; + + depsBuildBuild = with nixpkgs.buildPackages; + [ flex bison glibc stdenv.cc toolchain ]; + + src = fetchurl + { url = "http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/12.0-RELEASE/src.txz"; + sha256 = "0da393ac2174168a71c1c527d1453e07372295187d05c288250800cb152a889b"; + }; + + 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" + ]; + + sourceRoot = "."; + + patches = "${upstream.src}/repos/libports/src/lib/libc/patches/*.patch"; + patchFlags = "-p0 --strip 3"; + + libcPcIn = ./libc.pc.in; + libcSymbols = ./libc.symbols; +} diff --git a/ports/libc/libc-builder.sh b/ports/libc/libc-builder.sh new file mode 100755 index 0000000..ccf0e3b --- /dev/null +++ b/ports/libc/libc-builder.sh @@ -0,0 +1,255 @@ +source $preparePort/setup + +# +# 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 + + # + # CPU-architecture-specific headers + # + + # + # x86-specific headers + # + mkdir -p $includedir/spec/x86 + cp \ + lib/msun/x86/fenv.h \ + $includedir/spec/x86 + + cp -r sys/x86/include $includedir/x86 + + # + # i386-specific headers + # + mkdir -p $includedir/spec/x86_32/machine + cp \ + $(common_include_libc_arch_content i386 i386) \ + $includedir/spec/x86_32 + + cp \ + $(common_include_libc_arch_machine_content i386) \ + sys/i386/include/specialreg.h \ + sys/i386/include/npx.h \ + $includedir/spec/x86_32/machine + + # + # AMD64-specific headers + # + mkdir -p $includedir/spec/x86_64/machine + cp \ + $(common_include_libc_arch_content amd64 amd64) \ + $includedir/spec/x86_64 + + cp \ + $(common_include_libc_arch_machine_content amd64) \ + sys/amd64/include/specialreg.h \ + sys/amd64/include/fpu.h \ + $includedir/spec/x86_64/machine + + # + # ARM-specific headers + # + mkdir -p $includedir/spec/arm/machine + cp \ + $(common_include_libc_arch_content arm arm) \ + lib/msun/arm/fenv.h \ + $includedir/spec/arm + + cp \ + $(common_include_libc_arch_machine_content arm) \ + $includedir/spec/arm/machine + + copyIncludes $includedir/spec/arm/machine sys/arm/include \ + armreg.h atomic-v6.h ieee.h sysreg.h + + # + # ARM64-specific headers + # + mkdir -p $includedir/spec/arm_64/machine + cp \ + $(common_include_libc_arch_content arm64 aarch64) \ + lib/msun/aarch64/fenv.h \ + $includedir/spec/arm_64 + + cp \ + $(common_include_libc_arch_machine_content arm64) \ + $includedir/spec/arm_64/machine + + copyIncludes $includedir/spec/arm_64/machine sys/arm64/include/ \ + armreg.h + + + ############################################################## + + 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 + + mkdir -p $pkgconfigdir + substituteAll $libcPcIn $pkgconfigdir/libc.pc + compileStub $libcSymbols $dev/lib/libc.lib.so + + cp -rv . $source +} + + +genericBuild diff --git a/ports/libc/libc.pc.in b/ports/libc/libc.pc.in new file mode 100644 index 0000000..ab4c15c --- /dev/null +++ b/ports/libc/libc.pc.in @@ -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@ -I@includedir@/spec/x86_64 -I@includedir@/spec/x86 +Libs: -l:libc.lib.so diff --git a/ports/libc/libc.symbols b/ports/libc/libc.symbols new file mode 100644 index 0000000..4b8fd9b --- /dev/null +++ b/ports/libc/libc.symbols @@ -0,0 +1,1057 @@ +___runetype T +___tolower T +___toupper T +__assert T +__dn_expand T +__error T +__flt_rounds T +__fpclassifyd T +__fpclassifyf T +__has_sse D 4 +__h_errno T +__h_errno_set T +__inet_addr T +__inet_aton T +__inet_nsap_ntoa T +__inet_ntoa T +__inet_ntop T +__inet_pton T +__isthreaded B 4 +__mb_cur_max D 8 +___mb_cur_max D 50 +__res_init T +__res_query T +__res_state T +__srget T +__stderrp D 8 +__stdinp D 8 +__stdoutp D 8 +__swbuf T +__test_sse T +__xuname T +_exit T +_getlong T +_getshort T +a64l T +abort T +abs T +accept T +accept4 T +access T +alarm T +alphasort T +arc4random T +arc4random_addrandom T +arc4random_buf T +arc4random_stir T +arc4random_uniform T +asctime T +asctime_r T +asprintf T +atexit T +atof T +atoi T +atol T +atoll T +basename T +bcmp T +bcopy T +bind T +bsearch T +btowc T +bzero T +calloc T +cfgetispeed T +cfgetospeed T +cfmakeraw T +cfsetispeed T +cfsetospeed T +cfsetspeed T +cgetcap T +cgetclose T +cgetent T +cgetfirst T +cgetmatch T +cgetnext T +cgetnum T +cgetset T +cgetstr T +cgetustr T +chdir T +check_utility_compat T +chmod W +chown W +chroot W +clearerr T +clearerr_unlocked T +clock T +clock_gettime W +clock_getres W +close T +closedir T +closelog T +confstr T +connect T +creat W +crypt W +ctermid T +ctermid_r T +ctime T +ctime_r T +daemon T +dbopen W +des_cipher T +des_setkey T +difftime T +digittoint T +dirname T +div T +dl_iterate_phdr W +dladdr T +dlclose T +dlerror T +dlfunc T +dlinfo T +dllockinit W +dlopen T +dlsym T +dlvsym T +dprintf T +drand48 T +dup T +dup2 T +encrypt T +endfsent T +endgrent T +endnetgrent T +endpwent W +endttyent T +endusershell T +environ B 8 +erand48 T +err W +err_set_exit T +err_set_file T +errc T +errx T +execl T +execle T +execlp T +execv T +execvP T +execve T +execvp T +exit T +f_prealloc T +fchdir T +fchmod W +fchown W +fclose T +fcloseall W +fcntl T +fdatasync W +fdevname T +fdevname_r T +fdopen T +fdopendir T +feof T +feof_unlocked T +ferror T +ferror_unlocked T +fflagstostr T +fflush T +ffs T +ffsl T +ffsll T +fgetc T +fgetln T +fgetpos T +fgets T +fgetwc T +fgetwln T +fgetws T +fileno T +fileno_unlocked T +flock W +flockfile W +fls T +flsl T +flsll T +fmtcheck W +fmtmsg T +fnmatch T +fopen T +fork W +fpathconf W +fprintf T +fpurge T +fputc T +fputs T +fputwc T +fputws T +fread T +free T +freeaddrinfo T +freebsd7___semctl W +freebsd7_semctl T +freelocale T +freopen T +fscanf T +fseek T +fseeko T +fsetpos T +fstat T +fstatat T +fstatfs T +fstatvfs T +fsync T +ftell T +ftello T +ftok T +ftruncate T +ftrylockfile W +fts_children T +fts_close T +fts_get_clientptr T +fts_get_stream T +fts_open T +fts_read T +fts_set T +fts_set_clientptr T +ftw T +funlockfile W +funopen T +fwide T +fwprintf T +fwrite T +fwscanf T +gai_strerror T +getaddrinfo T +getbootfile T +getbsize T +getc T +getc_unlocked T +getchar T +getchar_unlocked T +getcontext W +getcwd T +getdelim T +getdirentries T +getdiskbyname T +getdomainname T +getdtablesize W +getegid W +getentropy W +getenv T +geteuid W +getfsent T +getfsfile T +getfsspec T +getfsstat W +getfstab T +getgid W +getgrent T +getgrent_r T +getgrgid T +getgrgid_r T +getgrnam T +getgrnam_r T +getgrouplist T +getgroups W +gethostbyaddr T +gethostbyaddr_r T +gethostbyname W +gethostid T +gethostname T +getline T +getloadavg T +getlogin T +getlogin_r T +getmntinfo T +getmode T +getnameinfo W +getnetgrent T +getopt T +getopt_long T +getopt_long_only T +getpagesize T +getpass T +getpeereid T +getpeername T +getpgrp W +getpid W +getppid W +getpriority W +getprogname W +getprotobyname T +getprotobyname_r T +getpwent W +getpwent_r W +getpwnam W +getpwnam_r W +getpwuid W +getpwuid_r W +getrandom W +getrlimit W +getrusage W +gets T +getservbyname W +getservbyport T +getservbyport_r T +getsid W +getsockname T +getsockopt T +getsubopt T +gettimeofday W +getttyent T +getttynam T +getuid W +getusershell T +getw T +getwc T +getwchar T +getwd T +glob T +globfree T +gmtime T +gmtime_r T +grantpt T +group_from_gid T +hcreate T +hdestroy T +heapsort T +hsearch T +imaxabs T +imaxdiv T +in6addr_any R 16 +in6addr_linklocal_allnodes R 16 +in6addr_loopback R 16 +in6addr_nodelocal_allnodes R 16 +index T +inet_addr W +inet_aton W +inet_lnaof W +inet_makeaddr W +inet_net_ntop W +inet_net_pton W +inet_neta W +inet_netof W +inet_network W +inet_nsap_addr W +inet_nsap_ntoa W +inet_ntoa W +inet_ntoa_r W +inet_ntop W +inet_pton W +initgroups T +initstate T +innetgr T +insque T +ioctl T +isalnum T +isalpha T +isascii T +isatty T +isblank T +iscntrl T +isdialuptty T +isdigit T +isgraph T +ishexnumber T +isideogram T +isinf W +islower T +isnan W +isnanf W +isnettty T +isnumber T +isphonogram T +isprint T +ispunct T +isrune T +issetugid T +isspace T +isspecial T +isupper T +iswalnum T +iswalpha T +iswascii T +iswblank T +iswcntrl T +iswctype T +iswdigit T +iswgraph T +iswhexnumber T +iswideogram T +iswlower T +iswnumber T +iswphonogram T +iswprint T +iswpunct T +iswrune T +iswspace T +iswspecial T +iswupper T +iswxdigit T +isxdigit T +jrand48 T +kill W +killpg T +ksem_init T +l64a T +l64a_r T +labs T +lcong48 T +ldexp T +ldiv T +lfind T +libc_select_notify V +link W +listen T +llabs T +lldiv T +localeconv T +localtime T +localtime_r T +lockf T +longjmp W +longjmperror T +lrand48 T +lsearch T +lseek T +lstat T +madvise W +makecontext W +malloc T +mblen T +mbrlen T +mbrtowc T +mbsinit T +mbsnrtowcs T +mbsrtowcs T +mbstowcs T +mbtowc T +memccpy T +memchr T +memcmp T +memcpy T +memmem T +memmove T +memrchr T +memset T +mergesort T +mkdir T +mkdtemp T +mkfifo W +mknod W +mkstemp T +mkstemps T +mktemp T +mktime T +mmap T +mprotect W +mrand48 T +msync T +munmap T +nanosleep W +clock_nanosleep W +newlocale T +nextwctype T +nftw T +nice T +nl_langinfo T +nlist T +nrand48 T +offtime T +open T +openat T +opendir T +openlog T +optarg B 8 +opterr D 4 +optind D 4 +optopt B 4 +optreset B 4 +pathconf W +pause W +pclose T +perror T +pipe T +poll W +ppoll W +popen T +posix2time T +posix_fadvise T +posix_madvise T +posix_spawn T +posix_spawn_file_actions_addclose T +posix_spawn_file_actions_adddup2 T +posix_spawn_file_actions_addopen T +posix_spawn_file_actions_destroy T +posix_spawn_file_actions_init T +posix_spawnattr_destroy T +posix_spawnattr_getflags T +posix_spawnattr_getpgroup T +posix_spawnattr_getschedparam T +posix_spawnattr_getschedpolicy T +posix_spawnattr_getsigdefault T +posix_spawnattr_getsigmask T +posix_spawnattr_init T +posix_spawnattr_setflags T +posix_spawnattr_setpgroup T +posix_spawnattr_setschedparam T +posix_spawnattr_setschedpolicy T +posix_spawnattr_setsigdefault T +posix_spawnattr_setsigmask T +posix_spawnp T +pread T +printf T +pselect W +psignal T +pthread_atfork T +pthread_attr_destroy T +pthread_attr_getdetachstate T +pthread_attr_getguardsize T +pthread_attr_getinheritsched T +pthread_attr_get_np T +pthread_attr_getschedparam T +pthread_attr_getschedpolicy T +pthread_attr_getscope T +pthread_attr_getstack T +pthread_attr_getstackaddr T +pthread_attr_getstacksize T +pthread_attr_init T +pthread_attr_setdetachstate T +pthread_attr_setguardsize T +pthread_attr_setinheritsched T +pthread_attr_setschedparam T +pthread_attr_setschedpolicy T +pthread_attr_setscope T +pthread_attr_setstackaddr T +pthread_attr_setstacksize T +pthread_cancel T +pthread_cleanup_pop T +pthread_cleanup_push T +pthread_cond_broadcast T +pthread_cond_destroy T +pthread_cond_init T +pthread_cond_signal T +pthread_cond_timedwait T +pthread_cond_wait T +pthread_condattr_destroy T +pthread_condattr_init T +pthread_condattr_setclock T +pthread_create W +pthread_detach T +pthread_equal T +pthread_exit T +pthread_getspecific T +pthread_join T +pthread_key_create T +pthread_key_delete T +pthread_kill T +pthread_main_np T +pthread_mutex_destroy T +pthread_mutex_init T +pthread_mutex_lock T +pthread_mutex_trylock T +pthread_mutex_unlock T +pthread_mutexattr_destroy T +pthread_mutexattr_init T +pthread_mutexattr_settype T +pthread_once T +pthread_rwlock_destroy T +pthread_rwlock_init T +pthread_rwlock_rdlock T +pthread_rwlock_tryrdlock T +pthread_rwlock_trywrlock T +pthread_rwlock_unlock T +pthread_rwlock_wrlock T +pthread_self T +pthread_setcancelstate T +pthread_setcanceltype T +pthread_setspecific T +pthread_sigmask T +pthread_testcancel T +ptsname T +putc T +putc_unlocked T +putchar T +putchar_unlocked T +putenv T +puts T +putw T +putwc T +putwchar T +pwrite T +qsort T +qsort_r T +radixsort T +raise W +rand T +rand_r T +random T +read T +readdir T +readdir_r T +readlink T +readpassphrase T +readv T +realloc T +reallocf T +realpath T +recv T +recvfrom T +recvmsg T +regcomp T +regerror T +regexec T +regfree T +register_printf_function T +register_printf_render T +register_printf_render_std T +remove T +remque T +rename T +rewind T +rewinddir T +rindex T +rmdir T +rpmatch T +sbrk W +scandir T +scanf T +sched_setparam W +sched_setscheduler W +sched_yield W +seed48 T +seekdir T +select W +sem_close T +semctl T +sem_destroy T +sem_getvalue T +semget W +sem_init T +sem_open T +semop W +sem_post T +sem_timedwait T +sem_trywait T +sem_unlink T +sem_wait T +send T +sendmsg W +sendto T +setbuf T +setbuffer T +setcontext W +setdomainname T +setegid W +setenv T +seteuid W +setfsent T +setfstab T +setgid W +setgrent T +setgroupent T +setgroups W +sethostid T +sethostname T +setitimer W +setjmp T +setkey T +setlinebuf T +setlocale T +setlogmask T +setmode T +setnetgrent T +setpassent W +setpgid W +setpgrp T +setpriority W +setprogname T +setpwent W +setregid W +setreuid W +setrgid T +setrlimit W +setruid T +setsid W +setsockopt T +setstate T +setttyent T +setuid W +setusershell T +setvbuf T +shutdown T +sigaction W +sigaddset T +sigblock T +sigdelset T +sigemptyset T +sigfillset T +sighold T +sigignore T +siginterrupt T +sigismember T +siglongjmp W +signal T +sigpause T +sigprocmask W +sigrelse T +sigset T +sigsetjmp T +sigsetmask T +sigsuspend W +sigvec T +sl_add T +sl_find T +sl_free T +sl_init T +sleep W +snprintf T +socket T +socketpair W +sprintf T +sradixsort T +srand T +srand48 T +sranddev T +srandom T +srandomdev T +sscanf T +stat T +statfs W +statvfs T +stpcpy T +stpncpy T +strcasecmp T +strcasestr T +strcat T +strchr T +strcmp T +strcoll T +strcpy T +strcspn T +strdup T +strerror T +strerror_r T +strfmon T +strftime T +strlcat T +strlcpy T +strlen T +strmode T +strncasecmp T +strncat T +strncmp T +strncpy T +strndup T +strnlen T +strnstr T +strpbrk T +strptime T +strrchr T +strsep T +strsignal T +strspn T +strstr T +strtod T +strtof T +strtofflags T +strtoimax T +strtok T +strtok_r W +strtol T +strtold T +strtoll T +strtonum T +strtoq T +strtoul T +strtoull T +strtoumax T +strtouq T +strunvis T +strunvisx T +strvis T +strvisx T +strxfrm T +suboptarg B 8 +swab T +swapcontext W +swprintf T +swscanf T +symlink T +sync W +sys_errlist D 776 +sys_nerr R 4 +sys_nsig R 4 +sys_siglist D 256 +sys_signame D 256 +syscall T +sysconf T +sysctl T +sysctlbyname T +sysctlnametomib T +syslog T +system W +tcdrain W +tcflow T +tcflush T +tcgetattr T +tcgetpgrp T +tcgetsid T +tcsendbreak T +tcsetattr T +tcsetpgrp T +tcsetsid T +tdelete T +telldir T +tempnam T +tfind T +time T +time2posix T +timegm T +timelocal T +timeoff T +times T +timezone T +tmpfile T +tmpnam T +toascii T +tolower T +toupper T +towctrans T +towlower T +towupper T +truncate W +tsearch T +ttyname T +ttyname_r T +ttyslot T +twalk T +tzname D 16 +tzset T +tzsetwall T +ualarm T +ulimit T +umask W +uname T +ungetc T +ungetwc T +unlink T +unlockpt T +unsetenv T +unvis T +uselocale T +user_from_uid T +usleep W +utimes W +utime W +vasprintf T +vdprintf T +verr T +verrc T +verrx T +vfork W +vfprintf T +vfscanf W +vfwprintf T +vfwscanf T +vis T +vprintf T +vscanf T +vsnprintf T +vsprintf T +vsscanf T +vswprintf T +vswscanf T +vsyslog T +vwarn T +vwarnc T +vwarnx T +vwprintf T +vwscanf T +wait W +wait3 T +waitpid W +warn W +warnc T +warnx T +wcpcpy T +wcpncpy T +wcrtomb T +wcscasecmp T +wcscat T +wcschr T +wcscmp T +wcscoll T +wcscpy T +wcscspn T +wcsdup T +wcsftime T +wcslcat T +wcslcpy T +wcslen T +wcsncasecmp T +wcsncat T +wcsncmp T +wcsncpy T +wcsnlen T +wcsnrtombs T +wcspbrk T +wcsrchr T +wcsrtombs T +wcsspn T +wcsstr T +wcstod T +wcstof T +wcstoimax T +wcstok T +wcstol T +wcstold T +wcstoll T +wcstombs T +wcstoul T +wcstoull T +wcstoumax T +wcswidth T +wcsxfrm T +wctob T +wctomb T +wctrans T +wctype T +wcwidth T +wmemchr T +wmemcmp T +wmemcpy T +wmemmove T +wmemset T +wordexp T +wordfree T +wprintf T +write T +writev T +wscanf T +xsi_sigpause T + + +# +# Symbols needed by libm +# +__mb_sb_limit D 4 +_DefaultRuneLocale D 4224 +_CurrentRuneLocale D 8 +__isinf T + + +# +# Public interface between Genode-component code and the libc runtime +# +_ZN4Libc9Component9constructERNS_3EnvE U +_ZN4Libc9Component10stack_sizeEv W +_ZN4Libc30execute_in_application_contextERNS_16Application_codeE T +_ZN4Libc19Select_handler_base6selectEiR6fd_setS2_S2_ T +_ZN4Libc19Select_handler_baseC1Ev T +_ZN4Libc19Select_handler_baseC2Ev T +_ZN4Libc19Select_handler_baseD1Ev T +_ZN4Libc19Select_handler_baseD2Ev T +_ZN4Libc10resume_allEv T +_ZN4Libc7suspendERNS_15Suspend_functorEm T +_Z16pthread_registryv T +_ZN16Pthread_registry6insertEP7pthread T +_ZN16Pthread_registry6removeEP7pthread T +_ZN16Pthread_registry8containsEP7pthread T +_ZN4Libc14pthread_createEPP7pthreadPFPvS3_ES3_mPKcPN6Genode11Cpu_sessionENS8_8Affinity8LocationE T +_ZN4Libc14pthread_createEPP7pthreadRN6Genode6ThreadE T + +# +# Libc plugin interface +# +_ZN4Libc16schedule_suspendEPFvvE T +_ZN4Libc25File_descriptor_allocator15find_by_libc_fdEi T +_ZN4Libc25File_descriptor_allocator4freeEPNS_15File_descriptorE T +_ZN4Libc25File_descriptor_allocator5allocEPNS_6PluginEPNS_14Plugin_contextEi T +_ZN4Libc25file_descriptor_allocatorEv T +_ZN4Libc6Plugin10getsockoptEPNS_15File_descriptorEiiPvPj T +_ZN4Libc6Plugin10setsockoptEPNS_15File_descriptorEiiPKvj T +_ZN4Libc6Plugin11getpeernameEPNS_15File_descriptorEP8sockaddrPj T +_ZN4Libc6Plugin11getsocknameEPNS_15File_descriptorEP8sockaddrPj T +_ZN4Libc6Plugin13getdirentriesEPNS_15File_descriptorEPcmPx T +_ZN4Libc6Plugin13getdirentriesEPNS_15File_descriptorEPcmPl T +_ZN4Libc6Plugin13supports_mmapEv T +_ZN4Libc6Plugin13supports_openEPKci T +_ZN4Libc6Plugin13supports_pipeEv T +_ZN4Libc6Plugin13supports_pollEv T +_ZN4Libc6Plugin13supports_statEPKc T +_ZN4Libc6Plugin14supports_mkdirEPKct T +_ZN4Libc6Plugin14supports_rmdirEPKc T +_ZN4Libc6Plugin15supports_accessEPKci T +_ZN4Libc6Plugin15supports_execveEPKcPKPcS5_ T +_ZN4Libc6Plugin15supports_renameEPKcS2_ T +_ZN4Libc6Plugin15supports_selectEiP6fd_setS2_S2_P7timeval T +_ZN4Libc6Plugin15supports_socketEiii T +_ZN4Libc6Plugin15supports_unlinkEPKc T +_ZN4Libc6Plugin16supports_symlinkEPKcS2_ T +_ZN4Libc6Plugin17supports_readlinkEPKcPcj T +_ZN4Libc6Plugin17supports_readlinkEPKcPcm T +_ZN4Libc6Plugin3dupEPNS_15File_descriptorE T +_ZN4Libc6Plugin4bindEPNS_15File_descriptorEPK8sockaddrj T +_ZN4Libc6Plugin4dup2EPNS_15File_descriptorES2_ T +_ZN4Libc6Plugin4mmapEPvmiiPNS_15File_descriptorEx T +_ZN4Libc6Plugin4mmapEPvmiiPNS_15File_descriptorEl T +_ZN4Libc6Plugin4openEPKci T +_ZN4Libc6Plugin4pipeEPPNS_15File_descriptorE T +_ZN4Libc6Plugin4pollERNS_15File_descriptorER6pollfd T +_ZN4Libc6Plugin4readEPNS_15File_descriptorEPvj T +_ZN4Libc6Plugin4readEPNS_15File_descriptorEPvm T +_ZN4Libc6Plugin4recvEPNS_15File_descriptorEPvji T +_ZN4Libc6Plugin4recvEPNS_15File_descriptorEPvmi T +_ZN4Libc6Plugin4sendEPNS_15File_descriptorEPKvji T +_ZN4Libc6Plugin4sendEPNS_15File_descriptorEPKvmi T +_ZN4Libc6Plugin4statEPKcP4stat T +_ZN4Libc6Plugin5closeEPNS_15File_descriptorE T +_ZN4Libc6Plugin5fcntlEPNS_15File_descriptorEil T +_ZN4Libc6Plugin5fstatEPNS_15File_descriptorEP4stat T +_ZN4Libc6Plugin5fsyncEPNS_15File_descriptorE T +_ZN4Libc6Plugin5ioctlEPNS_15File_descriptorEiPc T +_ZN4Libc6Plugin5lseekEPNS_15File_descriptorEli T +_ZN4Libc6Plugin5lseekEPNS_15File_descriptorExi T +_ZN4Libc6Plugin5mkdirEPKct T +_ZN4Libc6Plugin5msyncEPvmi T +_ZN4Libc6Plugin5rmdirEPKc T +_ZN4Libc6Plugin5writeEPNS_15File_descriptorEPKvj T +_ZN4Libc6Plugin5writeEPNS_15File_descriptorEPKvm T +_ZN4Libc6Plugin6acceptEPNS_15File_descriptorEP8sockaddrPj T +_ZN4Libc6Plugin6accessEPKci T +_ZN4Libc6Plugin6execveEPKcPKPcS5_ T +_ZN4Libc6Plugin6listenEPNS_15File_descriptorEi T +_ZN4Libc6Plugin6munmapEPvj T +_ZN4Libc6Plugin6munmapEPvm T +_ZN4Libc6Plugin6renameEPKcS2_ T +_ZN4Libc6Plugin6selectEiP6fd_setS2_S2_P7timeval T +_ZN4Libc6Plugin6sendtoEPNS_15File_descriptorEPKvjiPK8sockaddrj T +_ZN4Libc6Plugin6sendtoEPNS_15File_descriptorEPKvmiPK8sockaddrj T +_ZN4Libc6Plugin6socketEiii T +_ZN4Libc6Plugin6unlinkEPKc T +_ZN4Libc6Plugin7connectEPNS_15File_descriptorEPK8sockaddrj T +_ZN4Libc6Plugin7fstatfsEPNS_15File_descriptorEP6statfs T +_ZN4Libc6Plugin7recvmsgEPNS_15File_descriptorEP6msghdri T +_ZN4Libc6Plugin7symlinkEPKcS2_ T +_ZN4Libc6Plugin8priorityEv T +_ZN4Libc6Plugin8readlinkEPKcPcj T +_ZN4Libc6Plugin8readlinkEPKcPcm T +_ZN4Libc6Plugin8recvfromEPNS_15File_descriptorEPvjiP8sockaddrPj T +_ZN4Libc6Plugin8recvfromEPNS_15File_descriptorEPvmiP8sockaddrPj T +_ZN4Libc6Plugin8shutdownEPNS_15File_descriptorEi T +_ZN4Libc6Plugin9ftruncateEPNS_15File_descriptorEl T +_ZN4Libc6Plugin9ftruncateEPNS_15File_descriptorEx T +_ZN4Libc6Plugin10resume_allEv T +_ZN4Libc6PluginC1Ei T +_ZN4Libc6PluginC2Ei T +_ZN4Libc6PluginD0Ev T +_ZN4Libc6PluginD1Ev T +_ZN4Libc6PluginD2Ev T +_ZN4Libc9mem_allocEv T +_ZTIN4Libc6PluginE D 40 diff --git a/ports/libc/posix.pc.in b/ports/libc/posix.pc.in new file mode 100644 index 0000000..46974e9 --- /dev/null +++ b/ports/libc/posix.pc.in @@ -0,0 +1,5 @@ +Name: POSIX entrypoint +Description: Genode POSIX entrypoint library +Version: @DEPOT_VERSION@ +Requires: libc +Libs: -l:posix.lib.so diff --git a/ports/libm/default.nix b/ports/libm/default.nix new file mode 100644 index 0000000..58dd26c --- /dev/null +++ b/ports/libm/default.nix @@ -0,0 +1,31 @@ +{ preparePort, nixpkgs, toolchain, upstream }: + +let + version = "0.6.0"; +in +preparePort { + name = "libm-" + version; + outputs = [ "dev" ]; + inherit version; + + src = nixpkgs.fetchFromGitHub { + owner = "JuliaMath"; + repo = "openlibm"; + rev = "a96f0740e32c3d8aaa0a34c3988201018dfa90ce"; + sha256 = "08wfchmmr5200fvmn1kwq9byc1fhsq46hn0y5k8scdl74771c7gh"; + }; + + depsBuildBuild = with nixpkgs.buildPackages; [ stdenv.cc toolchain ]; + + buildPhase = + '' + mkdir -p $pkgconfigdir + compileStub ${./libm.symbols} $dev/lib/libm.lib.so + substituteAll ${./libm.pc.in} $pkgconfigdir/libm.pc + ''; + + installPhase = + '' + cp -rv include $dev/ + ''; +} diff --git a/ports/libm/libm.pc.in b/ports/libm/libm.pc.in new file mode 100644 index 0000000..a010a26 --- /dev/null +++ b/ports/libm/libm.pc.in @@ -0,0 +1,6 @@ +Name: Libm +Description: Genode C mathematic library +URL: https://genode.org/ +Version: @version@ +Cflags: -I@includedir@ +Libs: -l:libm.lib.so diff --git a/ports/libm/libm.symbols b/ports/libm/libm.symbols new file mode 100644 index 0000000..0943ecb --- /dev/null +++ b/ports/libm/libm.symbols @@ -0,0 +1,322 @@ +_ItL_aT R 384 +_ItL_atanhi R 64 +_ItL_atanlo R 64 +_ItL_pS0 R 16 +_ItL_pS1 R 16 +_ItL_pS2 R 16 +_ItL_pS3 R 16 +_ItL_pS4 R 16 +_ItL_pS5 R 16 +_ItL_pS6 R 16 +_ItL_pi_lo R 16 +_ItL_qS1 R 16 +_ItL_qS2 R 16 +_ItL_qS3 R 16 +_ItL_qS4 R 16 +_ItL_qS5 R 16 +__exp__D T +__fe_dfl_env R 32 +__fpclassifyd T +__fpclassifyf T +__fpclassifyl T +__ieee754_rem_pio2 T +__ieee754_rem_pio2f T +__isfinite T +__isfinitef T +__isfinitel T +__isinff T +__isinfl T +__isnanf T +__isnanl T +__isnormal T +__isnormalf T +__isnormall T +__kernel_cos T +__kernel_cosdf T +__kernel_cosl T +__kernel_rem_pio2 T +__kernel_sin T +__kernel_sindf T +__kernel_sinl T +__kernel_tan T +__kernel_tandf T +__kernel_tanl T +__ldexp_cexp T +__ldexp_cexpf T +__ldexp_exp T +__ldexp_expf T +__log__D T +__p1evll T +__polevll T +__scan_nan T +__signbit T +__signbitf T +__signbitl T +acos T +acosf T +acosh T +acoshf T +acoshl T +acosl T +asin T +asinf T +asinh T +asinhf T +asinhl T +asinl T +atan T +atan2 T +atan2f T +atan2l T +atanf T +atanh T +atanhf T +atanhl T +atanl T +cabs T +cabsf T +cabsl T +cacos T +cacosf T +cacosh T +cacoshf T +cacoshl T +cacosl T +carg T +cargf T +cargl T +casin T +casinf T +casinh T +casinhf T +casinhl T +casinl T +catan T +catanf T +catanh T +catanhf T +catanhl T +catanl T +cbrt T +cbrtf T +cbrtl T +ccos T +ccosf T +ccosh T +ccoshf T +ccoshl T +ccosl T +ceil T +ceilf T +ceill T +cexp T +cexpf T +cexpl T +cimag T +cimagf T +cimagl T +clog T +clogf T +clogl T +conj T +conjf T +conjl T +copysign T +copysignf T +copysignl T +cos T +cosf T +cosh T +coshf T +coshl T +cosl T +cpow T +cpowf T +cpowl T +cproj T +cprojf T +cprojl T +creal T +crealf T +creall T +csin T +csinf T +csinh T +csinhf T +csinhl T +csinl T +csqrt T +csqrtf T +csqrtl T +ctan T +ctanf T +ctanh T +ctanhf T +ctanhl T +ctanl T +erf T +erfc T +erfcf T +erfcl T +erff T +erfl T +exp T +exp2 T +exp2f T +exp2l T +expf T +expl T +expm1 T +expm1f T +expm1l T +fabs T +fabsf T +fabsl T +fdim T +fdimf T +fdiml T +fedisableexcept T +feenableexcept T +fegetenv T +feholdexcept T +feraiseexcept T +fesetexceptflag T +feupdateenv T +floor T +floorf T +floorl T +fma T +fmaf T +fmal T +fmax T +fmaxf T +fmaxl T +fmin T +fminf T +fminl T +fmod T +fmodf T +fmodl T +frexp T +frexpf T +frexpl T +hypot T +hypotf T +hypotl T +ilogb T +ilogbf T +ilogbl T +isinf T +isinff W +isnan T +isnanf W +isopenlibm T +j0 T +j0f T +j1 T +j1f T +jn T +jnf T +ldexp T +ldexpf T +ldexpl T +lgamma T +lgamma_r T +lgammaf T +lgammaf_r T +lgammal T +lgammal_r T +llrint T +llrintf T +llrintl T +llround T +llroundf T +llroundl T +log T +log10 T +log10f T +log10l T +log1p T +log1pf T +log1pl T +log2 T +log2f T +log2l T +logb T +logbf T +logbl T +logf T +logl T +lrint T +lrintf T +lrintl T +lround T +lroundf T +lroundl T +modf T +modff T +modfl T +nan T +nanf T +nanl T +nearbyint T +nearbyintf T +nearbyintl T +nextafter T +nextafterf T +nextafterl T +nexttoward T +nexttowardf T +nexttowardl T +pow T +powf T +powl T +remainder T +remainderf T +remainderl T +remquo T +remquof T +remquol T +rint T +rintf T +rintl T +round T +roundf T +roundl T +scalbln T +scalblnf T +scalblnl T +scalbn T +scalbnf T +scalbnl T +signgam B 4 +sin T +sincos T +sincosf T +sincosl T +sinf T +sinh T +sinhf T +sinhl T +sinl T +sqrt T +sqrtf T +sqrtl T +tan T +tanf T +tanh T +tanhf T +tanhl T +tanl T +tgamma T +tgammaf T +tgammal T +trunc T +truncf T +truncl T +y0 T +y0f T +y1 T +y1f T +yn T +ynf T diff --git a/ports/mesa/default.nix b/ports/mesa/default.nix new file mode 100644 index 0000000..0bac62a --- /dev/null +++ b/ports/mesa/default.nix @@ -0,0 +1,63 @@ +{ preparePort, nixpkgs, upstream }: + +let + version = "11.2.2"; + upstreamMesaDir = "${upstream.src}/repos/libports/src/lib/mesa"; +in +preparePort { + name = "mesa-${version}"; + outputs = [ "source" "dev" ]; + + depsBuildBuild = with nixpkgs.buildPackages; [ bison flex python ]; + + src = nixpkgs.fetchurl { + url = "https://mesa.freedesktop.org/archive/older-versions/11.x/${version}/mesa-${version}.tar.gz"; + sha256 = "e2453014cd2cc5337a5180cdeffe8cf24fffbb83e20a96888e2b01df868eaae6"; + }; + + tarFlags = "--files-from ${upstreamMesaDir}/files.list"; + + patches = "${upstreamMesaDir}/patches/*.patch"; + patchFlags = "-p4"; + + installPhase = + '' + mkdir -p $pkgconfigdir + + pushd src/compiler/glsl + bison -o glsl_parser.cpp -p "_mesa_glsl_" \ + --defines=glsl_parser.h glsl_parser.yy + + flex -o glsl_lexer.cpp glsl_lexer.ll + + pushd glcpp + bison -o sglcpp-parse.c \ + -p "glcpp_parser_" --defines=glcpp-parse.h \ + glcpp-parse.y + + flex -o glcpp-lex.c glcpp-lex.l + popd + popd + + pushd src/mesa/program + bison -o program_parse.tab.c \ + -p "_mesa_program_" --defines=program_parse.tab.h \ + program_parse.y + + flex -o lex.yy.c program_lexer.l + popd + + mkdir -p src/mapi/shared-glapi + pushd src/mapi/shared-glapi + python ../mapi_abi.py --mode lib --printer shared-glapi \ + ../glapi/gen/gl_and_es_API.xml > glapi_mapi_tmp.h + popd + + mv include $includedir + + substituteAll ${./mesa.pc.in} $pkgconfigdir/mesa.pc + + mkdir $source + mv * $source/ + ''; +} diff --git a/ports/mesa/mesa.pc.in b/ports/mesa/mesa.pc.in new file mode 100644 index 0000000..df32cea --- /dev/null +++ b/ports/mesa/mesa.pc.in @@ -0,0 +1,7 @@ +includedir=@includedir@ + +Name: mesa +Description: Mesa library +Version: @version@ +Libs: -l:mesa.lib.so +Cflags: -I${includedir} diff --git a/ports/stdcxx/default.nix b/ports/stdcxx/default.nix new file mode 100644 index 0000000..7d0603e --- /dev/null +++ b/ports/stdcxx/default.nix @@ -0,0 +1,102 @@ +{ preparePort, nixpkgs, toolchain, upstream }: + +let + inherit (nixpkgs.buildPackages) fetchurl fetchgit flex bison; + libc = import ./../libc { inherit preparePort nixpkgs toolchain upstream; }; + libm = import ./../libm { inherit preparePort nixpkgs toolchain upstream; }; + version = "8.3.0"; +in +preparePort { + name = "stdcxx-${version}"; + outputs = [ "source" "dev" ]; + inherit version; + + depsBuildBuild = with nixpkgs.buildPackages; [ pkgconfig stdenv.cc ]; + buildInputs = [ toolchain ]; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0b3xv411xhlnjmin2979nxcbnidgvzqdf4nbhix99x60dkzavfk4"; + }; + + tarFlags = + [ "gcc-${version}/libstdc++-v3" + "gcc-${version}/libgcc/gthr-single.h" + ]; + + sourceRoot = "gcc-${version}/libstdc++-v3"; + + patches = "${upstream.src}/repos/libports/src/lib/stdcxx/patches}/*.patch"; + patchFlags = "-p1"; + + buildPhase = + '' + for slop in include/c_global/cstdlib include/bits/std_abs.h include/c_global/cmath; do + sed 's/^#include_next/#include/' -i $slop + done + + mkdir -p $dev/lib + compileStub ${./stdcxx.symbols} $dev/lib/stdcxx.lib.so + ''; + + installPhase = + '' + mkdir -p $source $includedir/bits $includedir/config $pkgconfigdir + + local libcPc=${libc.dev}/lib/pkgconfig/libc.pc + local libmPc=${libm.dev}/lib/pkgconfig/libm.pc + libcCflags=`awk '/^Cflags/ { $1=""; print $0 }' $libcPc` \ + libmCflags=`awk '/^Cflags/ { $1=""; print $0 }' $libmPc` \ + substituteAll ${./stdcxx.pc.in} $pkgconfigdir/stdcxx.pc + + cp -r src config libsupc++ $source + + cp -r \ + include/* \ + include/c_compatibility/complex.h \ + include/c_compatibility/fenv.h \ + include/c_compatibility/tgmath.h \ + libsupc++/cxxabi.h \ + libsupc++/exception \ + libsupc++/initializer_list \ + libsupc++/new \ + libsupc++/typeinfo \ + $includedir + + cp -r \ + libsupc++/atomic_lockfree_defines.h \ + libsupc++/cxxabi_forced.h \ + libsupc++/cxxabi_init_exception.h \ + libsupc++/exception.h \ + libsupc++/exception_defines.h \ + libsupc++/exception_ptr.h \ + libsupc++/hash_bytes.h \ + libsupc++/nested_exception.h \ + config/cpu/generic/atomic_word.h \ + config/cpu/generic/cpu_defines.h \ + config/cpu/generic/cxxabi_tweaks.h \ + config/cpu/generic/opt/bits/opt_random.h \ + config/os/generic/ctype_base.h \ + config/os/generic/ctype_inline.h \ + config/os/generic/error_constants.h \ + config/os/generic/os_defines.h \ + config/locale/generic/messages_members.h \ + config/locale/generic/time_members.h \ + ${upstream.src}/repos/libports/include/stdcxx/bits/*.h \ + $includedir/bits + + cp -r \ + config/allocator/new_allocator_base.h \ + config/io/basic_file_stdio.h \ + config/io/c_io_stdio.h \ + config/locale/generic/c_locale.h \ + $includedir/config + + cp config/io/basic_file_stdio.h $includedir/bits/basic_file.h + cp config/allocator/new_allocator_base.h $includedir/bits/c++allocator.h + cp config/io/c_io_stdio.h $includedir/bits/c++io.h + cp config/locale/generic/c_locale.h $includedir/bits/c++locale.h + cp ../libgcc/gthr-single.h $includedir/bits/gthr.h + ''; + +} diff --git a/ports/stdcxx/stdcxx.pc.in b/ports/stdcxx/stdcxx.pc.in new file mode 100644 index 0000000..1195967 --- /dev/null +++ b/ports/stdcxx/stdcxx.pc.in @@ -0,0 +1,7 @@ +includedir=@includedir@ +Name: stdcxx +Description: Genode Standard C++ library +Version: @version@ +Requires: libc +Cflags: -D_GLIBCXX_HAVE_MBSTATE_T -D_GLIBCXX_ATOMIC_BUILTINS_4 -D_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC -I${includedir} -I${includedir}/std -I${includedir}/c_global @libcCflags@ @libmCflags@ +Libs: -l:stdcxx.lib.so diff --git a/ports/stdcxx/stdcxx.symbols b/ports/stdcxx/stdcxx.symbols new file mode 100644 index 0000000..4e45657 --- /dev/null +++ b/ports/stdcxx/stdcxx.symbols @@ -0,0 +1,864 @@ +_Z20_txnal_cow_string_D1Pv T +_Z23_txnal_cow_string_c_strPKv T +_Z23_txnal_sso_string_c_strPKv T +_Z26_txnal_logic_error_get_msgPv T +_Z27_txnal_cow_string_D1_commitPv T +_Z28_txnal_runtime_error_get_msgPv T +_Z35_txnal_cow_string_C1_for_exceptionsPvPKcS_ T +_ZGTtNKSt11logic_error4whatEv T +_ZGTtNKSt13runtime_error4whatEv T +_ZGTtNSt11logic_errorC1EPKc T +_ZGTtNSt11logic_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt11logic_errorC2EPKc T +_ZGTtNSt11logic_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt11logic_errorD0Ev T +_ZGTtNSt11logic_errorD1Ev T +_ZGTtNSt11logic_errorD2Ev T +_ZGTtNSt11range_errorC1EPKc T +_ZGTtNSt11range_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt11range_errorC2EPKc T +_ZGTtNSt11range_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt11range_errorD0Ev T +_ZGTtNSt11range_errorD1Ev T +_ZGTtNSt11range_errorD2Ev T +_ZGTtNSt12domain_errorC1EPKc T +_ZGTtNSt12domain_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt12domain_errorC2EPKc T +_ZGTtNSt12domain_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt12domain_errorD0Ev T +_ZGTtNSt12domain_errorD1Ev T +_ZGTtNSt12domain_errorD2Ev T +_ZGTtNSt12length_errorC1EPKc T +_ZGTtNSt12length_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt12length_errorC2EPKc T +_ZGTtNSt12length_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt12length_errorD0Ev T +_ZGTtNSt12length_errorD1Ev T +_ZGTtNSt12length_errorD2Ev T +_ZGTtNSt12out_of_rangeC1EPKc T +_ZGTtNSt12out_of_rangeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt12out_of_rangeC2EPKc T +_ZGTtNSt12out_of_rangeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt12out_of_rangeD0Ev T +_ZGTtNSt12out_of_rangeD1Ev T +_ZGTtNSt12out_of_rangeD2Ev T +_ZGTtNSt13runtime_errorC1EPKc T +_ZGTtNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt13runtime_errorC2EPKc T +_ZGTtNSt13runtime_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt13runtime_errorD0Ev T +_ZGTtNSt13runtime_errorD1Ev T +_ZGTtNSt13runtime_errorD2Ev T +_ZGTtNSt14overflow_errorC1EPKc T +_ZGTtNSt14overflow_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt14overflow_errorC2EPKc T +_ZGTtNSt14overflow_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt14overflow_errorD0Ev T +_ZGTtNSt14overflow_errorD1Ev T +_ZGTtNSt14overflow_errorD2Ev T +_ZGTtNSt15underflow_errorC1EPKc T +_ZGTtNSt15underflow_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt15underflow_errorC2EPKc T +_ZGTtNSt15underflow_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt15underflow_errorD0Ev T +_ZGTtNSt15underflow_errorD1Ev T +_ZGTtNSt15underflow_errorD2Ev T +_ZGTtNSt16invalid_argumentC1EPKc T +_ZGTtNSt16invalid_argumentC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt16invalid_argumentC2EPKc T +_ZGTtNSt16invalid_argumentC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZGTtNSt16invalid_argumentD0Ev T +_ZGTtNSt16invalid_argumentD1Ev T +_ZGTtNSt16invalid_argumentD2Ev T +_ZN11__gnu_debug19_Safe_iterator_base12_M_get_mutexEv T +_ZN11__gnu_debug19_Safe_iterator_base16_M_attach_singleEPNS_19_Safe_sequence_baseEb T +_ZN11__gnu_debug19_Safe_iterator_base16_M_detach_singleEv T +_ZN11__gnu_debug19_Safe_iterator_base8_M_resetEv T +_ZN11__gnu_debug19_Safe_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb T +_ZN11__gnu_debug19_Safe_iterator_base9_M_detachEv T +_ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv T +_ZN11__gnu_debug19_Safe_sequence_base13_M_detach_allEv T +_ZN11__gnu_debug19_Safe_sequence_base16_M_attach_singleEPNS_19_Safe_iterator_baseEb T +_ZN11__gnu_debug19_Safe_sequence_base16_M_detach_singleEPNS_19_Safe_iterator_baseE T +_ZN11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv T +_ZN11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv T +_ZN11__gnu_debug19_Safe_sequence_base7_M_swapERS0_ T +_ZN11__gnu_debug19_Safe_sequence_base9_M_attachEPNS_19_Safe_iterator_baseEb T +_ZN11__gnu_debug19_Safe_sequence_base9_M_detachEPNS_19_Safe_iterator_baseE T +_ZN11__gnu_debug25_Safe_local_iterator_base16_M_attach_singleEPNS_19_Safe_sequence_baseEb T +_ZN11__gnu_debug25_Safe_local_iterator_base16_M_detach_singleEv T +_ZN11__gnu_debug25_Safe_local_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb T +_ZN11__gnu_debug25_Safe_local_iterator_base9_M_detachEv T +_ZN11__gnu_debug30_Safe_unordered_container_base13_M_detach_allEv T +_ZN11__gnu_debug30_Safe_unordered_container_base15_M_attach_localEPNS_19_Safe_iterator_baseEb T +_ZN11__gnu_debug30_Safe_unordered_container_base15_M_detach_localEPNS_19_Safe_iterator_baseE T +_ZN11__gnu_debug30_Safe_unordered_container_base22_M_attach_local_singleEPNS_19_Safe_iterator_baseEb T +_ZN11__gnu_debug30_Safe_unordered_container_base22_M_detach_local_singleEPNS_19_Safe_iterator_baseE T +_ZN11__gnu_debug30_Safe_unordered_container_base7_M_swapERS0_ T +_ZN14__gnu_parallel9_Settings3getEv T +_ZN14__gnu_parallel9_Settings3setERS0_ T +_ZN9__gnu_cxx12__atomic_addEPVii T +_ZN9__gnu_cxx15__concat_size_tEPcmm T +_ZN9__gnu_cxx15__snprintf_liteEPcmPKcP13__va_list_tag T +_ZN9__gnu_cxx17__pool_alloc_base11_S_end_freeE B 8 +_ZN9__gnu_cxx17__pool_alloc_base12_M_get_mutexEv T +_ZN9__gnu_cxx17__pool_alloc_base12_S_free_listE B 128 +_ZN9__gnu_cxx17__pool_alloc_base12_S_heap_sizeE B 8 +_ZN9__gnu_cxx17__pool_alloc_base13_S_start_freeE B 8 +_ZN9__gnu_cxx17__pool_alloc_base16_M_get_free_listEm T +_ZN9__gnu_cxx17__pool_alloc_base17_M_allocate_chunkEmRi T +_ZN9__gnu_cxx17__pool_alloc_base9_M_refillEm T +_ZN9__gnu_cxx18__exchange_and_addEPVii T +_ZN9__gnu_cxx26__throw_insufficient_spaceEPKcS1_ T +_ZN9__gnu_cxx9free_list6_M_getEm T +_ZN9__gnu_cxx9free_list8_M_clearEv T +_ZNK11__gnu_debug16_Error_formatter10_M_messageENS_13_Debug_msg_idE T +_ZNK11__gnu_debug16_Error_formatter10_Parameter14_M_print_fieldEPKS0_PKc T +_ZNK11__gnu_debug16_Error_formatter10_Parameter20_M_print_descriptionEPKS0_ T +_ZNK11__gnu_debug16_Error_formatter13_M_print_wordEPKc T +_ZNK11__gnu_debug16_Error_formatter15_M_print_stringEPKc T +_ZNK11__gnu_debug16_Error_formatter17_M_get_max_lengthEv T +_ZNK11__gnu_debug16_Error_formatter8_M_errorEv T +_ZNK11__gnu_debug19_Safe_iterator_base11_M_singularEv T +_ZNK11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_ T +_ZNK11__gnu_debug25_Safe_local_iterator_base16_M_get_containerEv T +_ZNKSt10bad_typeid4whatEv T +_ZNKSt10error_code23default_error_conditionEv T +_ZNKSt11logic_error4whatEv T +_ZNKSt12bad_weak_ptr4whatEv T +_ZNKSt12future_error4whatEv T +_ZNKSt13random_device13_M_getentropyEv T +_ZNKSt13runtime_error4whatEv T +_ZNKSt16bad_array_length4whatEv T +_ZNKSt17bad_function_call4whatEv T +_ZNKSt19__iosfail_type_info11__do_upcastEPKN10__cxxabiv117__class_type_infoEPPv T +_ZNKSt20bad_array_new_length4whatEv T +_ZNKSt3_V214error_category10_M_messageB5cxx11Ei T +_ZNKSt3_V214error_category10_M_messageEi T +_ZNKSt3_V214error_category10equivalentERKSt10error_codei T +_ZNKSt3_V214error_category10equivalentEiRKSt15error_condition T +_ZNKSt3_V214error_category23default_error_conditionEi T +_ZNKSt6locale2id5_M_idEv T +_ZNKSt6locale4nameB5cxx11Ev T +_ZNKSt6locale4nameEv T +_ZNKSt6locale5facet11_M_cow_shimEPKNS_2idE T +_ZNKSt6locale5facet11_M_sso_shimEPKNS_2idE T +_ZNKSt6localeeqERKS_ T +_ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEm T +_ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm T +_ZNKSt8bad_cast4whatEv T +_ZNKSt8ios_base7failure4whatEv T +_ZNKSt8ios_base7failureB5cxx114whatEv T +_ZNKSt9bad_alloc4whatEv T +_ZNKSt9type_info10__do_catchEPKS_PPvj T +_ZNKSt9type_info11__do_upcastEPKN10__cxxabiv117__class_type_infoEPPv T +_ZNKSt9type_info14__is_pointer_pEv T +_ZNKSt9type_info15__is_function_pEv T +_ZNSt10__num_base11_S_atoms_inE D 8 +_ZNSt10__num_base12_S_atoms_outE D 8 +_ZNSt10__num_base15_S_format_floatERKSt8ios_basePcc T +_ZNSt10bad_typeidD0Ev T +_ZNSt10bad_typeidD1Ev T +_ZNSt10bad_typeidD2Ev T +_ZNSt10ctype_base5alnumE R 4 +_ZNSt10ctype_base5alphaE R 4 +_ZNSt10ctype_base5blankE R 4 +_ZNSt10ctype_base5cntrlE R 4 +_ZNSt10ctype_base5digitE R 4 +_ZNSt10ctype_base5graphE R 4 +_ZNSt10ctype_base5lowerE R 4 +_ZNSt10ctype_base5printE R 4 +_ZNSt10ctype_base5punctE R 4 +_ZNSt10ctype_base5spaceE R 4 +_ZNSt10ctype_base5upperE R 4 +_ZNSt10ctype_base6xdigitE R 4 +_ZNSt10money_base18_S_default_patternE R 4 +_ZNSt10money_base20_S_construct_patternEccc T +_ZNSt10money_base8_S_atomsE D 8 +_ZNSt11logic_errorC1EPKc T +_ZNSt11logic_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt11logic_errorC1ERKS_ T +_ZNSt11logic_errorC1ERKSs T +_ZNSt11logic_errorC2EPKc T +_ZNSt11logic_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt11logic_errorC2ERKS_ T +_ZNSt11logic_errorC2ERKSs T +_ZNSt11logic_errorD0Ev T +_ZNSt11logic_errorD1Ev T +_ZNSt11logic_errorD2Ev T +_ZNSt11logic_erroraSERKS_ T +_ZNSt11range_errorC1EPKc T +_ZNSt11range_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt11range_errorC1ERKSs T +_ZNSt11range_errorC2EPKc T +_ZNSt11range_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt11range_errorC2ERKSs T +_ZNSt11range_errorD0Ev T +_ZNSt11range_errorD1Ev T +_ZNSt11range_errorD2Ev T +_ZNSt11regex_errorC1ENSt15regex_constants10error_typeE T +_ZNSt11regex_errorC2ENSt15regex_constants10error_typeE T +_ZNSt11regex_errorD0Ev T +_ZNSt11regex_errorD1Ev T +_ZNSt11regex_errorD2Ev T +_ZNSt12__cow_stringC1EOS_ T +_ZNSt12__cow_stringC1EPKcm T +_ZNSt12__cow_stringC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12__cow_stringC1ERKS_ T +_ZNSt12__cow_stringC1ERKSs T +_ZNSt12__cow_stringC1Ev T +_ZNSt12__cow_stringC2EOS_ T +_ZNSt12__cow_stringC2EPKcm T +_ZNSt12__cow_stringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12__cow_stringC2ERKS_ T +_ZNSt12__cow_stringC2ERKSs T +_ZNSt12__cow_stringC2Ev T +_ZNSt12__cow_stringD1Ev T +_ZNSt12__cow_stringD2Ev T +_ZNSt12__cow_stringaSEOS_ T +_ZNSt12__cow_stringaSERKS_ T +_ZNSt12__sso_stringC1EOS_ T +_ZNSt12__sso_stringC1EPKcm T +_ZNSt12__sso_stringC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12__sso_stringC1ERKS_ T +_ZNSt12__sso_stringC1ERKSs T +_ZNSt12__sso_stringC1Ev T +_ZNSt12__sso_stringC2EOS_ T +_ZNSt12__sso_stringC2EPKcm T +_ZNSt12__sso_stringC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12__sso_stringC2ERKS_ T +_ZNSt12__sso_stringC2ERKSs T +_ZNSt12__sso_stringC2Ev T +_ZNSt12__sso_stringD1Ev T +_ZNSt12__sso_stringD2Ev T +_ZNSt12__sso_stringaSEOS_ T +_ZNSt12__sso_stringaSERKS_ T +_ZNSt12bad_weak_ptrD0Ev T +_ZNSt12bad_weak_ptrD1Ev T +_ZNSt12bad_weak_ptrD2Ev T +_ZNSt12domain_errorC1EPKc T +_ZNSt12domain_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12domain_errorC1ERKSs T +_ZNSt12domain_errorC2EPKc T +_ZNSt12domain_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12domain_errorC2ERKSs T +_ZNSt12domain_errorD0Ev T +_ZNSt12domain_errorD1Ev T +_ZNSt12domain_errorD2Ev T +_ZNSt12future_errorD0Ev T +_ZNSt12future_errorD1Ev T +_ZNSt12future_errorD2Ev T +_ZNSt12length_errorC1EPKc T +_ZNSt12length_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12length_errorC1ERKSs T +_ZNSt12length_errorC2EPKc T +_ZNSt12length_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12length_errorC2ERKSs T +_ZNSt12length_errorD0Ev T +_ZNSt12length_errorD1Ev T +_ZNSt12length_errorD2Ev T +_ZNSt12out_of_rangeC1EPKc T +_ZNSt12out_of_rangeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12out_of_rangeC1ERKSs T +_ZNSt12out_of_rangeC2EPKc T +_ZNSt12out_of_rangeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt12out_of_rangeC2ERKSs T +_ZNSt12out_of_rangeD0Ev T +_ZNSt12out_of_rangeD1Ev T +_ZNSt12out_of_rangeD2Ev T +_ZNSt12placeholders2_1E R 1 +_ZNSt12placeholders2_2E R 1 +_ZNSt12placeholders2_3E R 1 +_ZNSt12placeholders2_4E R 1 +_ZNSt12placeholders2_5E R 1 +_ZNSt12placeholders2_6E R 1 +_ZNSt12placeholders2_7E R 1 +_ZNSt12placeholders2_8E R 1 +_ZNSt12placeholders2_9E R 1 +_ZNSt12placeholders3_10E R 1 +_ZNSt12placeholders3_11E R 1 +_ZNSt12placeholders3_12E R 1 +_ZNSt12placeholders3_13E R 1 +_ZNSt12placeholders3_14E R 1 +_ZNSt12placeholders3_15E R 1 +_ZNSt12placeholders3_16E R 1 +_ZNSt12placeholders3_17E R 1 +_ZNSt12placeholders3_18E R 1 +_ZNSt12placeholders3_19E R 1 +_ZNSt12placeholders3_20E R 1 +_ZNSt12placeholders3_21E R 1 +_ZNSt12placeholders3_22E R 1 +_ZNSt12placeholders3_23E R 1 +_ZNSt12placeholders3_24E R 1 +_ZNSt12placeholders3_25E R 1 +_ZNSt12placeholders3_26E R 1 +_ZNSt12placeholders3_27E R 1 +_ZNSt12placeholders3_28E R 1 +_ZNSt12placeholders3_29E R 1 +_ZNSt12system_errorD0Ev T +_ZNSt12system_errorD1Ev T +_ZNSt12system_errorD2Ev T +_ZNSt13random_device14_M_init_pretr1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt13random_device14_M_init_pretr1ERKSs T +_ZNSt13random_device16_M_getval_pretr1Ev T +_ZNSt13random_device7_M_finiEv T +_ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt13random_device7_M_initERKSs T +_ZNSt13random_device9_M_getvalEv T +_ZNSt13runtime_errorC1EPKc T +_ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt13runtime_errorC1ERKS_ T +_ZNSt13runtime_errorC1ERKSs T +_ZNSt13runtime_errorC2EPKc T +_ZNSt13runtime_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt13runtime_errorC2ERKS_ T +_ZNSt13runtime_errorC2ERKSs T +_ZNSt13runtime_errorD0Ev T +_ZNSt13runtime_errorD1Ev T +_ZNSt13runtime_errorD2Ev T +_ZNSt13runtime_erroraSERKS_ T +_ZNSt14overflow_errorC1EPKc T +_ZNSt14overflow_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt14overflow_errorC1ERKSs T +_ZNSt14overflow_errorC2EPKc T +_ZNSt14overflow_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt14overflow_errorC2ERKSs T +_ZNSt14overflow_errorD0Ev T +_ZNSt14overflow_errorD1Ev T +_ZNSt14overflow_errorD2Ev T +_ZNSt15_List_node_base4hookEPS_ T +_ZNSt15_List_node_base4swapERS_S0_ T +_ZNSt15_List_node_base6unhookEv T +_ZNSt15_List_node_base7reverseEv T +_ZNSt15_List_node_base8transferEPS_S0_ T +_ZNSt15underflow_errorC1EPKc T +_ZNSt15underflow_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt15underflow_errorC1ERKSs T +_ZNSt15underflow_errorC2EPKc T +_ZNSt15underflow_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt15underflow_errorC2ERKSs T +_ZNSt15underflow_errorD0Ev T +_ZNSt15underflow_errorD1Ev T +_ZNSt15underflow_errorD2Ev T +_ZNSt16bad_array_lengthD0Ev T +_ZNSt16bad_array_lengthD1Ev T +_ZNSt16bad_array_lengthD2Ev T +_ZNSt16invalid_argumentC1EPKc T +_ZNSt16invalid_argumentC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt16invalid_argumentC1ERKSs T +_ZNSt16invalid_argumentC2EPKc T +_ZNSt16invalid_argumentC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt16invalid_argumentC2ERKSs T +_ZNSt16invalid_argumentD0Ev T +_ZNSt16invalid_argumentD1Ev T +_ZNSt16invalid_argumentD2Ev T +_ZNSt17bad_function_callD0Ev T +_ZNSt17bad_function_callD1Ev T +_ZNSt17bad_function_callD2Ev T +_ZNSt19__iosfail_type_infoD0Ev T +_ZNSt19__iosfail_type_infoD1Ev T +_ZNSt19__iosfail_type_infoD2Ev T +_ZNSt20bad_array_new_lengthD0Ev T +_ZNSt20bad_array_new_lengthD1Ev T +_ZNSt20bad_array_new_lengthD2Ev T +_ZNSt21__numeric_limits_base10has_denormE R 4 +_ZNSt21__numeric_limits_base10is_boundedE R 1 +_ZNSt21__numeric_limits_base10is_integerE R 1 +_ZNSt21__numeric_limits_base11round_styleE R 4 +_ZNSt21__numeric_limits_base12has_infinityE R 1 +_ZNSt21__numeric_limits_base12max_digits10E R 4 +_ZNSt21__numeric_limits_base12max_exponentE R 4 +_ZNSt21__numeric_limits_base12min_exponentE R 4 +_ZNSt21__numeric_limits_base13has_quiet_NaNE R 1 +_ZNSt21__numeric_limits_base14is_specializedE R 1 +_ZNSt21__numeric_limits_base14max_exponent10E R 4 +_ZNSt21__numeric_limits_base14min_exponent10E R 4 +_ZNSt21__numeric_limits_base15has_denorm_lossE R 1 +_ZNSt21__numeric_limits_base15tinyness_beforeE R 1 +_ZNSt21__numeric_limits_base17has_signaling_NaNE R 1 +_ZNSt21__numeric_limits_base5radixE R 4 +_ZNSt21__numeric_limits_base5trapsE R 1 +_ZNSt21__numeric_limits_base6digitsE R 4 +_ZNSt21__numeric_limits_base8digits10E R 4 +_ZNSt21__numeric_limits_base8is_exactE R 1 +_ZNSt21__numeric_limits_base9is_iec559E R 1 +_ZNSt21__numeric_limits_base9is_moduloE R 1 +_ZNSt21__numeric_limits_base9is_signedE R 1 +_ZNSt3_V214error_categoryD0Ev T +_ZNSt3_V214error_categoryD1Ev T +_ZNSt3_V214error_categoryD2Ev T +_ZNSt3_V215system_categoryEv T +_ZNSt3_V216generic_categoryEv T +_ZNSt3tr18__detail12__prime_listE R 2440 +_ZNSt6__norm15_List_node_base4hookEPS0_ T +_ZNSt6__norm15_List_node_base4swapERS0_S1_ T +_ZNSt6__norm15_List_node_base6unhookEv T +_ZNSt6__norm15_List_node_base7reverseEv T +_ZNSt6__norm15_List_node_base8transferEPS0_S1_ T +_ZNSt6chrono12system_clock3nowEv T +_ZNSt6chrono12system_clock9is_steadyE R 1 +_ZNSt6chrono3_V212steady_clock3nowEv T +_ZNSt6chrono3_V212steady_clock9is_steadyE R 1 +_ZNSt6chrono3_V212system_clock3nowEv T +_ZNSt6chrono3_V212system_clock9is_steadyE R 1 +_ZNSt6gslice8_IndexerC1EmRKSt8valarrayImES4_ T +_ZNSt6gslice8_IndexerC2EmRKSt8valarrayImES4_ T +_ZNSt6locale10_S_classicE B 8 +_ZNSt6locale11_M_coalesceERKS_S1_i T +_ZNSt6locale13_S_categoriesE D 8 +_ZNSt6locale13_S_initializeEv T +_ZNSt6locale17_S_twinned_facetsE D 272 +_ZNSt6locale18_S_initialize_onceEv T +_ZNSt6locale21_S_normalize_categoryEi T +_ZNSt6locale2id11_S_refcountE B 4 +_ZNSt6locale3allE R 4 +_ZNSt6locale4noneE R 4 +_ZNSt6locale4timeE R 4 +_ZNSt6locale5_Impl10_S_id_timeE D 56 +_ZNSt6locale5_Impl11_S_id_ctypeE D 56 +_ZNSt6locale5_Impl13_M_init_extraEPPNS_5facetE T +_ZNSt6locale5_Impl13_M_init_extraEPvS1_PKcS3_ T +_ZNSt6locale5_Impl13_S_id_collateE D 24 +_ZNSt6locale5_Impl13_S_id_numericE D 56 +_ZNSt6locale5_Impl14_S_id_messagesE D 24 +_ZNSt6locale5_Impl14_S_id_monetaryE D 72 +_ZNSt6locale5_Impl16_M_install_cacheEPKNS_5facetEm T +_ZNSt6locale5_Impl16_M_install_facetEPKNS_2idEPKNS_5facetE T +_ZNSt6locale5_Impl16_M_replace_facetEPKS0_PKNS_2idE T +_ZNSt6locale5_Impl19_M_replace_categoryEPKS0_PKPKNS_2idE T +_ZNSt6locale5_Impl19_S_facet_categoriesE D 56 +_ZNSt6locale5_Impl21_M_replace_categoriesEPKS0_i T +_ZNSt6locale5_ImplC1EPKcm T +_ZNSt6locale5_ImplC1ERKS0_m T +_ZNSt6locale5_ImplC1Em T +_ZNSt6locale5_ImplC2EPKcm T +_ZNSt6locale5_ImplC2ERKS0_m T +_ZNSt6locale5_ImplC2Em T +_ZNSt6locale5_ImplD1Ev T +_ZNSt6locale5_ImplD2Ev T +_ZNSt6locale5ctypeE R 4 +_ZNSt6locale5facet11_S_c_localeE B 8 +_ZNSt6locale5facet13_S_get_c_nameEv T +_ZNSt6locale5facet15_S_get_c_localeEv T +_ZNSt6locale5facet17_S_clone_c_localeERPi T +_ZNSt6locale5facet18_S_create_c_localeERPiPKcS1_ T +_ZNSt6locale5facet18_S_initialize_onceEv T +_ZNSt6locale5facet19_S_destroy_c_localeERPi T +_ZNSt6locale5facet20_S_lc_ctype_c_localeEPiPKc T +_ZNSt6locale5facet9_S_c_nameE R 2 +_ZNSt6locale5facetD0Ev T +_ZNSt6locale5facetD1Ev T +_ZNSt6locale5facetD2Ev T +_ZNSt6locale6globalERKS_ T +_ZNSt6locale7classicEv T +_ZNSt6locale7collateE R 4 +_ZNSt6locale7numericE R 4 +_ZNSt6locale8messagesE R 4 +_ZNSt6locale8monetaryE R 4 +_ZNSt6locale9_S_globalE B 8 +_ZNSt6localeC1EPKc T +_ZNSt6localeC1EPNS_5_ImplE T +_ZNSt6localeC1ERKS_ T +_ZNSt6localeC1ERKS_PKci T +_ZNSt6localeC1ERKS_S1_i T +_ZNSt6localeC1Ev T +_ZNSt6localeC2EPKc T +_ZNSt6localeC2EPNS_5_ImplE T +_ZNSt6localeC2ERKS_ T +_ZNSt6localeC2ERKS_PKci T +_ZNSt6localeC2ERKS_S1_i T +_ZNSt6localeC2Ev T +_ZNSt6localeD1Ev T +_ZNSt6localeD2Ev T +_ZNSt6localeaSERKS_ T +_ZNSt8__detail12__prime_listE R 2440 +_ZNSt8__detail15_List_node_base10_M_reverseEv T +_ZNSt8__detail15_List_node_base11_M_transferEPS0_S1_ T +_ZNSt8__detail15_List_node_base4swapERS0_S1_ T +_ZNSt8__detail15_List_node_base7_M_hookEPS0_ T +_ZNSt8__detail15_List_node_base9_M_unhookEv T +_ZNSt8bad_castD0Ev T +_ZNSt8bad_castD1Ev T +_ZNSt8bad_castD2Ev T +_ZNSt8ios_base10floatfieldE R 4 +_ZNSt8ios_base10scientificE R 4 +_ZNSt8ios_base11adjustfieldE R 4 +_ZNSt8ios_base13_M_grow_wordsEib T +_ZNSt8ios_base15sync_with_stdioEb T +_ZNSt8ios_base17_M_call_callbacksENS_5eventE T +_ZNSt8ios_base17register_callbackEPFvNS_5eventERS_iEi T +_ZNSt8ios_base20_M_dispose_callbacksEv T +_ZNSt8ios_base2inE R 4 +_ZNSt8ios_base3appE R 4 +_ZNSt8ios_base3ateE R 4 +_ZNSt8ios_base3begE R 4 +_ZNSt8ios_base3curE R 4 +_ZNSt8ios_base3decE R 4 +_ZNSt8ios_base3endE R 4 +_ZNSt8ios_base3hexE R 4 +_ZNSt8ios_base3octE R 4 +_ZNSt8ios_base3outE R 4 +_ZNSt8ios_base4Init11_S_refcountE B 4 +_ZNSt8ios_base4Init20_S_synced_with_stdioE D 1 +_ZNSt8ios_base4InitC1Ev T +_ZNSt8ios_base4InitC2Ev T +_ZNSt8ios_base4InitD1Ev T +_ZNSt8ios_base4InitD2Ev T +_ZNSt8ios_base4leftE R 4 +_ZNSt8ios_base5fixedE R 4 +_ZNSt8ios_base5imbueERKSt6locale T +_ZNSt8ios_base5rightE R 4 +_ZNSt8ios_base5truncE R 4 +_ZNSt8ios_base6badbitE R 4 +_ZNSt8ios_base6binaryE R 4 +_ZNSt8ios_base6eofbitE R 4 +_ZNSt8ios_base6skipwsE R 4 +_ZNSt8ios_base6xallocEv T +_ZNSt8ios_base7_M_initEv T +_ZNSt8ios_base7_M_moveERS_ T +_ZNSt8ios_base7_M_swapERS_ T +_ZNSt8ios_base7failbitE R 4 +_ZNSt8ios_base7failureB5cxx11C1EPKcRKSt10error_code T +_ZNSt8ios_base7failureB5cxx11C1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt8ios_base7failureB5cxx11C1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt10error_code T +_ZNSt8ios_base7failureB5cxx11C2EPKcRKSt10error_code T +_ZNSt8ios_base7failureB5cxx11C2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZNSt8ios_base7failureB5cxx11C2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt10error_code T +_ZNSt8ios_base7failureB5cxx11D0Ev T +_ZNSt8ios_base7failureB5cxx11D1Ev T +_ZNSt8ios_base7failureB5cxx11D2Ev T +_ZNSt8ios_base7failureC1ERKSs T +_ZNSt8ios_base7failureC2ERKSs T +_ZNSt8ios_base7failureD0Ev T +_ZNSt8ios_base7failureD1Ev T +_ZNSt8ios_base7failureD2Ev T +_ZNSt8ios_base7goodbitE R 4 +_ZNSt8ios_base7showposE R 4 +_ZNSt8ios_base7unitbufE R 4 +_ZNSt8ios_base8internalE R 4 +_ZNSt8ios_base8showbaseE R 4 +_ZNSt8ios_base9basefieldE R 4 +_ZNSt8ios_base9boolalphaE R 4 +_ZNSt8ios_base9showpointE R 4 +_ZNSt8ios_base9uppercaseE R 4 +_ZNSt8ios_baseC1Ev T +_ZNSt8ios_baseC2Ev T +_ZNSt8ios_baseD0Ev T +_ZNSt8ios_baseD1Ev T +_ZNSt8ios_baseD2Ev T +_ZNSt9__cxx199815_List_node_base4hookEPS0_ T +_ZNSt9__cxx199815_List_node_base4swapERS0_S1_ T +_ZNSt9__cxx199815_List_node_base6unhookEv T +_ZNSt9__cxx199815_List_node_base7reverseEv T +_ZNSt9__cxx199815_List_node_base8transferEPS0_S1_ T +_ZNSt9bad_allocD0Ev T +_ZNSt9bad_allocD1Ev T +_ZNSt9bad_allocD2Ev T +_ZNSt9type_infoD0Ev T +_ZNSt9type_infoD1Ev T +_ZNSt9type_infoD2Ev T +_ZSt11_Hash_bytesPKvmm T +_ZSt15_Fnv_hash_bytesPKvmm T +_ZSt15future_categoryv T +_ZSt15get_new_handlerv T +_ZSt15set_new_handlerPFvvE T +_ZSt16__throw_bad_castv T +_ZSt17__gslice_to_indexmRKSt8valarrayImES2_RS0_ T +_ZSt17__throw_bad_allocv T +_ZSt17__verify_groupingPKcmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE T +_ZSt17__verify_groupingPKcmRKSs T +_ZSt17iostream_categoryv T +_ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base T +_ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base T +_ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base T +_ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base T +_ZSt18__throw_bad_typeidv T +_ZSt19__throw_ios_failurePKc T +_ZSt19__throw_logic_errorPKc T +_ZSt19__throw_range_errorPKc T +_ZSt19__throw_regex_errorNSt15regex_constants10error_typeE T +_ZSt20_Rb_tree_black_countPKSt18_Rb_tree_node_baseS1_ T +_ZSt20_Rb_tree_rotate_leftPSt18_Rb_tree_node_baseRS0_ T +_ZSt20__throw_domain_errorPKc T +_ZSt20__throw_future_errori T +_ZSt20__throw_length_errorPKc T +_ZSt20__throw_out_of_rangePKc T +_ZSt20__throw_system_errori T +_ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_ T +_ZSt21__destroy_ios_failurePv T +_ZSt21__throw_bad_exceptionv T +_ZSt21__throw_runtime_errorPKc T +_ZSt22__throw_overflow_errorPKc T +_ZSt22__verify_grouping_implPKcmS0_m T +_ZSt23__construct_ios_failurePvPKc T +_ZSt23__throw_underflow_errorPKc T +_ZSt24__is_ios_failure_handlerPKN10__cxxabiv117__class_type_infoE T +_ZSt24__throw_invalid_argumentPKc T +_ZSt24__throw_out_of_range_fmtPKcz T +_ZSt25__throw_bad_function_callv T +_ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_ T +_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_ T +_ZSt3cin B 280 +_ZSt4cerr B 272 +_ZSt4clog B 272 +_ZSt4cout B 272 +_ZSt4wcin B 280 +_ZSt5wcerr B 272 +_ZSt5wclog B 272 +_ZSt5wcout B 272 +_ZSt7nothrow R 1 +_ZdaPv T +_ZdaPvRKSt9nothrow_t T +_ZdaPvm T +_ZdlPv T +_ZdlPvRKSt9nothrow_t T +_ZdlPvm T +_Znam T +_ZnamRKSt9nothrow_t T +_Znwm T +_ZnwmRKSt9nothrow_t T +__cxa_bad_cast T +__cxa_bad_typeid T +__cxa_throw_bad_array_length T +__cxa_throw_bad_array_new_length T + +# manually added typeinfo, vtable and VTT symbols + +_ZTINSt6locale5facetE V +_ZTISo V +_ZTISt11regex_error V +_ZTISt13runtime_error V +_ZTISt15basic_streambufIcSt11char_traitsIcEE V +_ZTISt16invalid_argument W +_ZTISt5ctypeIcE V +_ZTISt7codecvtIcc11__mbstate_tE V +_ZTISt8ios_base V +_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE V +_ZTTNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE V +_ZTTNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE V +_ZTTSt14basic_ifstreamIcSt11char_traitsIcEE V +_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE V +_ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE V +_ZTVNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE V +_ZTVNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE V +_ZTVNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEE V +_ZTVSt11regex_error V +_ZTVSt13basic_filebufIcSt11char_traitsIcEE V +_ZTVSt14basic_ifstreamIcSt11char_traitsIcEE V +_ZTVSt14basic_ofstreamIcSt11char_traitsIcEE V +_ZTVSt15basic_streambufIcSt11char_traitsIcEE V +_ZTVSt16invalid_argument V +_ZTVSt9basic_iosIcSt11char_traitsIcEE V + +# manually added template-related symbols + +_ZNKSt12__basic_fileIcE7is_openEv T +_ZNKSt5ctypeIcE13_M_widen_initEv T +_ZNKSt9type_infoeqERKS_ T +_ZNSi6ignoreEli T +_ZNSi7getlineEPclc T +_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei T +_ZNSt12__basic_fileIcE5closeEv T +_ZNSt12__basic_fileIcE6xsgetnEPcl T +_ZNSt12__basic_fileIcE6xsputnEPKcl T +_ZNSt12__basic_fileIcE7seekoffElSt12_Ios_Seekdir T +_ZNSt12__basic_fileIcE7seekoffExSt12_Ios_Seekdir T +_ZNSt12__basic_fileIcE8xsputn_2EPKclS2_l T +_ZNSt12__basic_fileIcE9showmanycEv T +_ZNSt12__basic_fileIcEC1EPi T +_ZNSt12__basic_fileIcED1Ev T +_ZNSt5ctypeIcE2idE B 8 +_ZNSt7codecvtIcc11__mbstate_tE2idE B 8 +_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_ T +_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE T + +# manually added weak symbols + +_ZNKSt15basic_streambufIcSt11char_traitsIcEE4gptrEv W +_ZNKSt15basic_streambufIcSt11char_traitsIcEE4pptrEv W +_ZNKSt15basic_streambufIcSt11char_traitsIcEE5ebackEv W +_ZNKSt15basic_streambufIcSt11char_traitsIcEE5egptrEv W +_ZNKSt15basic_streambufIcSt11char_traitsIcEE5epptrEv W +_ZNKSt15basic_streambufIcSt11char_traitsIcEE5pbaseEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12find_last_ofEcm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcmm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEcm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17find_first_not_ofEPKcmm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE3endEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4backEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4copyEPcmm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEPKcm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEPKcmm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5beginEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5emptyEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEPKcm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEPKcmm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEcm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEv W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareERKS4_ W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEmmPKc W +_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm W +_ZNKSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE3strEv W +_ZNKSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv W +_ZNKSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEE3strEv W +_ZNKSt9basic_iosIcSt11char_traitsIcEE3badEv W +_ZNKSt9basic_iosIcSt11char_traitsIcEE3eofEv W +_ZNKSt9basic_iosIcSt11char_traitsIcEE4failEv W +_ZNSaIcEC1ERKS_ W +_ZNSaIcEC1Ev W +_ZNSaIcEC2ERKS_ W +_ZNSaIcEC2Ev W +_ZNSaIcED1Ev W +_ZNSaIcED2Ev W +_ZNSdC1Ev W +_ZNSdC2Ev W +_ZNSi10_M_extractIdEERSiRT_ W +_ZNSi10_M_extractIfEERSiRT_ W +_ZNSi10_M_extractIjEERSiRT_ W +_ZNSi10_M_extractImEERSiRT_ W +_ZNSi10_M_extractIyEERSiRT_ W +_ZNSi3getERc W +_ZNSi4peekEv W +_ZNSi7getlineEPcl W +_ZNSi7putbackEc W +_ZNSirsERd W +_ZNSirsERf W +_ZNSirsERi W +_ZNSirsERj W +_ZNSo3putEc W +_ZNSo5flushEv W +_ZNSo5tellpEv W +_ZNSo5writeEPKcl W +_ZNSo9_M_insertIPKvEERSoT_ W +_ZNSo9_M_insertIbEERSoT_ W +_ZNSo9_M_insertIdEERSoT_ W +_ZNSo9_M_insertIeEERSoT_ W +_ZNSo9_M_insertIlEERSoT_ W +_ZNSo9_M_insertImEERSoT_ W +_ZNSo9_M_insertIxEERSoT_ W +_ZNSo9_M_insertIyEERSoT_ W +_ZNSoC1Ev W +_ZNSoC2Ev W +_ZNSoD0Ev W +_ZNSoD1Ev W +_ZNSoD2Ev W +_ZNSolsEPFRSoS_E W +_ZNSolsEPFRSt8ios_baseS0_E W +_ZNSolsEd W +_ZNSolsEf W +_ZNSolsEi W +_ZNSolsEj W +_ZNSolsEl W +_ZNSolsEm W +_ZNSolsEs W +_ZNSolsEx W +_ZNSolsEy W +_ZNSt13basic_filebufIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode W +_ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv W +_ZNSt13basic_filebufIcSt11char_traitsIcEEC1Ev W +_ZNSt13basic_filebufIcSt11char_traitsIcEED1Ev W +_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode W +_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev W +_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode W +_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev W +_ZNSt15basic_streambufIcSt11char_traitsIcEE4setgEPcS3_S3_ W +_ZNSt15basic_streambufIcSt11char_traitsIcEE4setpEPcS3_ W +_ZNSt15basic_streambufIcSt11char_traitsIcEE4syncEv W +_ZNSt15basic_streambufIcSt11char_traitsIcEE5gbumpEi W +_ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale W +_ZNSt15basic_streambufIcSt11char_traitsIcEE5pbumpEi W +_ZNSt15basic_streambufIcSt11char_traitsIcEE5uflowEv W +_ZNSt15basic_streambufIcSt11char_traitsIcEE6xsgetnEPcl W +_ZNSt15basic_streambufIcSt11char_traitsIcEE6xsputnEPKcl W +_ZNSt15basic_streambufIcSt11char_traitsIcEEC1Ev W +_ZNSt15basic_streambufIcSt11char_traitsIcEEC2Ev W +_ZNSt15basic_streambufIcSt11char_traitsIcEED0Ev W +_ZNSt15basic_streambufIcSt11char_traitsIcEED1Ev W +_ZNSt15basic_streambufIcSt11char_traitsIcEED2Ev W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_capacityEm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderC1EPcRKS3_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEmc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_set_lengthEm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcS5_S5_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE14_M_replace_auxEmmmc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE3endEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4backEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4swapERS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5beginEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5eraseEmm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendERKS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEmc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKcm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6insertEmPKc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6insertEmmc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6resizeEm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6resizeEmc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEPc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7replaceEN9__gnu_cxx17__normal_iteratorIPKcS4_EES9_S8_S8_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7replaceEmmPKc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEmm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8pop_backEv W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_assignERKS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEmmPKcm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EOS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcmRKS3_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1ERKS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EmcRKS3_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2EOS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2EPKcRKS3_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2EmcRKS3_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEPKc W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLERKS4_ W +_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc W +_ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm W +_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode W +_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev W +_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode W +_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEED1Ev W +_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode W +_ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev W +_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E W +_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate W +_ZNSt9basic_iosIcSt11char_traitsIcEE5imbueERKSt6locale W +_ZNSt9basic_iosIcSt11char_traitsIcEEC1Ev W +_ZNSt9basic_iosIcSt11char_traitsIcEEC2Ev W +_ZNSt9basic_iosIcSt11char_traitsIcEED0Ev W +_ZNSt9basic_iosIcSt11char_traitsIcEED1Ev W +_ZNSt9basic_iosIcSt11char_traitsIcEED2Ev W +_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l W +_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ W +_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc W +_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c W +_ZStlsIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_St13_Setprecision W +_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE W +_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_ W +_ZTv0_n24_NSoD0Ev W +_ZTv0_n24_NSoD1Ev W diff --git a/ports/zlib/default.nix b/ports/zlib/default.nix new file mode 100644 index 0000000..78c017f --- /dev/null +++ b/ports/zlib/default.nix @@ -0,0 +1,23 @@ +{ preparePort, nixpkgs }: + +preparePort { + inherit (nixpkgs.zlib) name src; + outputs = [ "dev" ]; + VERSION = nixpkgs.zlib.version; + + buildPhase = + '' + mkdir -p $pkgconfigdir + substituteAllInPlace zlib.pc.in + sed \ + -e "s|Libs:.*|Libs: -l:zlib.lib.so|" \ + -e "/@/d" \ + < zlib.pc.in > $pkgconfigdir/zlib.pc + ''; + + installPhase = + '' + mkdir -p $includedir + cp *.h $includedir + ''; +} diff --git a/release.nix b/release.nix new file mode 100644 index 0000000..10e2bc5 --- /dev/null +++ b/release.nix @@ -0,0 +1,16 @@ +{ genodepkgs ? builtins.fetchGit ./. +, nixpkgs ? builtins.fetchGit + { url = "git://depot.h4ck.me/srv/git/nixpkgs"; + ref = "genode"; + } +}: + +{ + build.x86_64 = + let pkgs = import ./default.nix + { inherit (nixpkgs); + system = { config = "x86_64-unknown-genode"; }; + }; + in + { inherit (pkgs) upstream ports; }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..028507d --- /dev/null +++ b/shell.nix @@ -0,0 +1,37 @@ +{ nixpkgs, toolchain, dhallPackages, pkgs }: + +let + args = + { name = "genode-dev-env"; + buildInputs = with nixpkgs.buildPackages; + [ toolchain + stdenv.glibc.dev + git tup + ccache + pkgconfig + pkgs.upstream.dev + pkgs.ports.libc.dev + ]; + + GENODE_DEV = pkgs.upstream.dev; + + shellHook = + '' + export DHALL_PRELUDE=${dhallPackages.prelude}/package.dhall + export DHALL_GENODE=${dhallPackages.genode}/package.dhall + export DHALL_GENODE_TYPES=${dhallPackages.genode}/types.dhall + export PROMPT_DIRTRIM=2 + export PS1="\[\033[1;30m\]dev: [\[\033[1;37m\]\w\[\033[1;30m\]] $\[\033[0m\] " + export PS2="\[\033[1;30m\]>\[\033[0m\] " + ''; + # Setup a prompt with a distinct appearance + }; +in +nixpkgs.buildPackages.mkShell + ( args + // { passthru = + { mkShell = { buildInputs, ... }@args': nixpkgs.buildPackages.mkShell + ( args // args' // { buildInputs = args.buildInputs ++ args'.buildInputs; } ); + }; + } + ) diff --git a/tool/default.nix b/tool/default.nix new file mode 100644 index 0000000..fa1b53a --- /dev/null +++ b/tool/default.nix @@ -0,0 +1,477 @@ +/* + * \brief Tools and utility functions + * \author Emery Hemingway + * \date 2014-09-30 + */ + +{ nixpkgs ? import { } }: + +with builtins; + +rec { + inherit nixpkgs; + inherit (nixpkgs) fetchurl; + + ## + # Add a prefix to a list of strings. + addPrefix = prefix: map (s: prefix+s); + + ## + # Determine if any of the following libs are shared. + anyShared = libs: + let h = head libs; in + if libs == [] then false else + if h.shared or false then true else anyShared (tail libs); + + ## + # Drop a suffix from the end of a string. + dropSuffix = suf: str: + let + strL = stringLength str; + sufL = stringLength suf; + in + if lessThan strL sufL || substring (sub strL sufL) strL str != suf + then abort "${str} does not have suffix ${suf}" + else substring 0 (sub strL sufL) str; + + ## + # Generate a list of file paths from a directory and + # filenames. + fromDir = dir: map (s: dir+("/"+s)); + + ## + # Utility functions for gathering sources. + fromGlob = + dir: glob: + let + dirName = dir.name or baseNameOf (toString dir); + in + import (shellDerivation { + name = "${dirName}-glob.nix"; + script = ./from-glob.sh; + #PATH="${nixpkgs.coreutils}/bin"; + inherit dir glob; + }); + + fromPath = path: [ [ path (baseNameOf (toString path)) ] ]; + fromPaths = paths: map (p: [ p (baseNameOf (toString p)) ]) paths; + + ## + # Filter out libs that are not derivations + filterFakeLibs = libs: filter (lib: hasAttr "shared" lib) libs; + + ## + # Test if a string ends in '.h'. + hasDotH = s: substring (sub (stringLength s) 2) 2 s == ".h"; + hasDotHH = s: substring (sub (stringLength s) 3) 3 s == ".hh"; + hasDotHPP = s: substring (sub (stringLength s) 4) 4 s == ".hpp"; + + ## + # Filter out everything but *.h on a path. + # Prevents files that exist alongside headers from changing header path hash. + filterHeaders = dir: filterSource + (path: type: hasDotH path || hasDotHH path || hasDotHPP path || type == "directory") + dir; + + ## + # Find a filename in a search path. + findFile = fn: searchPath: + if searchPath == [] then [] + else + let + sp = head searchPath; + fn' = sp + "/${fn}"; + in + if builtins.typeOf fn' != "path" then [] else + if pathExists fn' then + [ { key = fn'; relative = fn; } ] + else findFile fn (tail searchPath); + + findIncludes = main: path: + map (x: [ x.key x.relative ]) (genericClosure { + startSet = [ { key = main; relative = baseNameOf (toString main); } ]; + operator = + { key, ... }: + let + includes = import (includesOf key); + includesFound = + nixpkgs.lib.concatMap + (fn: findFile fn ([ (dirOf main) ] ++ path)) + includes; + in includesFound; + }); + + ## + # Recursively find libraries. + findLibraries = libs: + let + list = map (lib: { key = lib.name; inherit lib; }); + in + map (x: x.lib) (genericClosure { + startSet = list libs; + operator = { key, lib }: list lib.libs or []; + }); + + ## + # Recursively find libraries to link. + findLinkLibraries = libs: + let + list = libs: map + (lib: { key = lib.name; inherit lib; }) + (filter (lib: hasAttr "drvPath" lib) libs); + in + map (x: x.lib) (genericClosure { + startSet = list libs; + operator = + { key, lib }: + if lib.shared then [] + else list lib.libs or []; + }); + + findLocalIncludes = main: path: + let path' = [ (dirOf main) ] ++ path; in + map (x: [ x.key x.relative ]) (genericClosure { + startSet = [ { key = main; relative = baseNameOf (toString main); } ]; + operator = + { key, ... }: + let + includes = import (localIncludesOf key); + includesFound = + nixpkgs.lib.concatMap + (fn: findFile fn path') + includes; + in includesFound; + }); + + ## + # Recursively find shared libraries. + findRuntimeLibraries = libs: + let + filter = libs: builtins.filter (lib: lib.shared) libs; + list = libs: + map (lib: { key = lib.name; inherit lib; }) libs; + in + filter (map (x: x.lib) (genericClosure { + startSet = list libs; + operator = + { key, lib }: + list ([lib ] ++ lib.libs); + })); + + ## + # Determine if a string has the given suffix. + hasSuffix = suf: str: + let + strL = stringLength str; + sufL = stringLength suf; + in + if lessThan strL sufL then false else + substring (sub strL sufL) strL str == suf; + + includesOf = file: + import (derivation { + name = + if typeOf file == "path" + then "${baseNameOf (toString file)}-includes" + else "includes"; + system = currentSystem; + preferLocalBuild = true; + builder = "${nixpkgs.perl}/bin/perl"; + args = [ ./find-includes.pl ]; + inherit file; + }); + + ## + # Create a bootable ISO. + iso = + { name, contents, kernel, kernelArgs }: + shellDerivation { + name = "${name}.iso"; + script = ./iso.sh; + PATH="${nixpkgs.coreutils}/bin:${nixpkgs.cdrkit}/bin:${nixpkgs.binutils}/bin"; + inherit kernel kernelArgs; + inherit (nixpkgs) syslinux cdrkit; + sources = map (x: x.source) contents; + targets = map (x: x.target) contents; + }; + + ## + # Generate a contents list of runtime libraries for a package. + # This will go away as tool.runtime matures. + libContents = contents: builtins.concatLists (map ( + content: + map (source: { target = "/"; inherit source; }) content.source.runtime.libs or [] + ) contents); + + localIncludesOf = main: derivation { + name = + if typeOf main == "path" + then "${baseNameOf (toString main)}-local-includes" + else "local-includes"; + system = currentSystem; + preferLocalBuild = true; + builder = "${nixpkgs.perl}/bin/perl"; + args = [ ./find-local-includes.pl ]; + inherit main; + }; + + ## + # Merge an attr between two sets. + mergeAttr = + name: s1: s2: + let + a1 = getAttr name s1; + a2 = getAttr name s2; + type1 = typeOf a1; + type2 = typeOf a2; + in + if type1 == "null" then a2 else if type2 == "null" then a1 else + if type1 != type2 then abort "cannot merge ${name}s of type ${type1} and ${type2}" else + if type1 == "set" then mergeSet a1 a2 else + if type1 == "list" then a1 ++ a2 else + if type1 == "string" then "${a1} ${a2}" else + #if type1 == "int" then add a1 a2 else + abort "cannot merge ${type1} ${name} ${toString a1} ${toString a2}"; + + ## + # Merge two sets together. + mergeSet = s1: s2: + s1 // s2 // (listToAttrs (map + (name: { inherit name; value = mergeAttr name s1 s2; }) + (attrNames (intersectAttrs s1 s2)) + )); + + ## + # Merge a list of sets. + mergeSets = + sets: + if sets == [] then {} else + mergeSet (head sets) (mergeSets (tail sets)); + + newDir = + name: contents: + derivation { + inherit name contents; + system = builtins.currentSystem; + preferLocalBuild = true; + builder = shell; + PATH="${nixpkgs.coreutils}/bin"; + args = [ "-e" "-c" '' + mkdir -p $out ; \ + for i in $contents; do cp -Hr $i $out; done + '' ]; + }; + + ## + # Generate a list of paths from a path and a shell glob. + pathsFromGlob = dir: glob: + let path = toString dir; in + import (derivation { + name = "${baseNameOf path}-glob.nix"; + args = [ "-e" "-O" "nullglob" ./path-from-glob.sh ]; + inherit dir glob path; + preferLocalBuild = true; + }); + + preparePort = import ./prepare-port { inherit nixpkgs; }; + + # Concatenate the named attr found in pkgs. + propagate = attrName: pkgs: + let + pkg = head pkgs; + in + if pkgs == [] then [] else + ( if hasAttr attrName pkg + then getAttr attrName pkg + else [] + ) ++ + (propagate attrName (tail pkgs)); + + + ## + # Replace substring a with substring b in string s. + replaceInString = + a: b: s: + let + al = stringLength a; + bl = stringLength b; + sl = stringLength s; + in + if al == 0 then s else + if sl == 0 then "" else + if ((substring 0 al s) == a) then + b+(replaceInString a b (substring al sl s)) + else + (substring 0 1 s) + (replaceInString a b (substring 1 sl s)); + + shell = nixpkgs.bash + "/bin/sh"; + + # Save some typing when creating derivation that use our shell. + shellDerivation = { script, ... } @ args: + derivation ( (removeAttrs args [ "script" ]) // + { system = builtins.currentSystem; + builder = shell; + args = [ "-e" script ]; + } + ); + + singleton = x: [x]; + + # Bootability is not assured, so its really system image. + systemImage = import ./system-image { inherit nixpkgs; }; + bootImage = systemImage; # get rid of this + + + wildcard = + path: glob: + let + relativePaths = import (shellDerivation { + name = "files.nix"; + PATH="${nixpkgs.coreutils}/bin"; + script = ./wildcard.sh; + inherit path glob; + + }); + in + map (rp: (path+"/${rp}")) relativePaths; + + # Appends string context from another string + addContextFrom = a: b: substring 0 0 a + b; + + # Compares strings not requiring context equality + # Obviously, a workaround but works on all Nix versions + eqStrings = a: b: addContextFrom b a == addContextFrom a b; + + + ## + # Cut a string with a separator and produces a list of strings which were + # separated by this separator. e.g., + # `splitString "." "foo.bar.baz"' returns ["foo" "bar" "baz"]. + # From nixpkgs. + splitString = _sep: _s: + let + sep = addContextFrom _s _sep; + s = addContextFrom _sep _s; + sepLen = stringLength sep; + sLen = stringLength s; + lastSearch = sLen - sepLen; + startWithSep = startAt: + substring startAt sepLen s == sep; + + recurse = index: startAt: + let cutUntil = i: [(substring startAt (i - startAt) s)]; in + if index < lastSearch then + if startWithSep index then + let restartAt = index + sepLen; in + cutUntil index ++ recurse restartAt restartAt + else + recurse (index + 1) startAt + else + cutUntil sLen; + in + recurse 0 0; + ## + # What I thought builtins.match would do. + matchPattern = pat: str: + concatLists ( + map + ( l: + let m = match pat l; in + if m == null then [] else m + ) + (splitString "\n" str) + ); + + ## + # Generate a set of local ("") and system (<>) + # preprocessor include directives from a file. + relativeIncludes = file: + let + matches = pattern: lines: + concatLists (filter (x: x != null) (map (match pattern) lines)); + lines = splitString "\n" (readFile file); + in + { local = matches ''.*#include\s*"([^>]*)".*'' lines; + system = matches ''.*#include\s*<([^>]*)>.*'' lines; + }; + + ## + # Find a file in a set of directories. + findFile' = key: dirs: + if substring 0 1 key == "!" then builtins.trace "found a !key" key else + if dirs == [] then null else + let abs = (builtins.head dirs) +"/${key}"; in + if builtins.pathExists abs then abs + else findFile' key (builtins.tail dirs); + + ## + # Generate a set of relative to absolute include mappings from a file. + # This set includes a mapping from the orginal file basename to its + # absolute path. + # + # The genericClosure primative applies an operation to a list of sets that + # contain the attribute 'key'. This operation returns a similar list of sets, + # and genericClosure appends elements of that list that contain a key + # that does not already exist in the previous set. All sets returned by this + # operation contain a function to resolve the relative path at 'key' into an + # absolute one at 'abs', and a function to parse the absolute path at 'abs' + # into a list of relative includes at 'inc'. GenericClosure discards any set + # with a relative path at 'key' that it has already been seen, and thus due + # to lazy evaulation, no relative path is resolved or parsed twice. + # + # A ! is prepended to the files of the initial set, to differentiate them from + # files with unsolved locations and to satisfy the requirement that strings + # not directly reference store paths in findFile' + includesOfFiles = files: searchPath: + let + concat = sets: + if sets == [] then {} else + let x = head sets; in + (if x.abs == null || substring 0 1 x.key == "!" then {} else { "${x.key}" = x.abs; }) // concat (tail sets); + in + concat (genericClosure { + # Can the startSet really be filled with elements sharing a key? + startSet = map (abs: { key = "!${abs}"; inherit abs; inc = includesOf abs; }) files; + operator = + { key, abs, inc }: if abs == null then [] else let abs' = abs; in + (map + (key: rec { inherit key; abs = (findFile' key searchPath); inc = includesOf abs; }) + inc.system) + ++ + (map + (key: rec { inherit key; abs = (findFile' key (if typeOf abs' == "path" then searchPath ++ [ (dirOf abs') ] else searchPath)); inc = relativeIncludes abs; }) + inc.local); + }); + + ## + # Load expressions from a directory path and apply func. + loadExpressions = func: path: + let + dirSet = builtins.readDir path; + default = + if builtins.hasAttr "default.nix" dirSet + then func (import (path + "/default.nix")) + else {}; + in + default // (builtins.listToAttrs (builtins.filter (x: x != {}) (map + (name: + let + type = builtins.getAttr name dirSet; + more = loadExpressions func (path + "/${name}"); + in + if type == "directory" + then { inherit name; value = more; } + else + if + (type == "regular" || type == "symlink") && + (hasSuffix ".nix" name) + then + { name = dropSuffix ".nix" name; + value = func (import (path+"/${name}")); + } + else { } + ) + (builtins.attrNames dirSet) + ))); + +} diff --git a/tool/prepare-port/builder.sh b/tool/prepare-port/builder.sh new file mode 100644 index 0000000..ec88ec5 --- /dev/null +++ b/tool/prepare-port/builder.sh @@ -0,0 +1,12 @@ +export PATH= +for i in $initialPath; do + if [ "$i" = / ]; then i=; fi + PATH=$PATH${PATH:+:}$i/bin +done + +mkdir $out + +sed \ + -e "s^@LD_SCRIPT_SO@^$LD_SCRIPT_SO^g" \ + -e "s^@initialPath@^$initialPath^g" \ + < $setup > $out/setup diff --git a/tool/prepare-port/default-builder.sh b/tool/prepare-port/default-builder.sh new file mode 100644 index 0000000..0f81f60 --- /dev/null +++ b/tool/prepare-port/default-builder.sh @@ -0,0 +1,2 @@ +source $preparePort/setup +genericBuild diff --git a/tool/prepare-port/default.nix b/tool/prepare-port/default.nix new file mode 100644 index 0000000..67ee398 --- /dev/null +++ b/tool/prepare-port/default.nix @@ -0,0 +1,42 @@ +{ nixpkgs }: +let + shell = nixpkgs.buildPackages.bash + "/bin/sh"; + + initialPath = with nixpkgs.buildPackages; + [ coreutils + findutils + diffutils + gawk + gnugrep + gnused + gnutar + patch + gzip + bzip2 + xz + ]; +in +{ name +, outputs ? [ "out" ] +, preferLocalBuild ? true +, ... } @ attrs: +derivation (attrs // { + inherit name outputs initialPath; + + preparePort = derivation { + name = "prepare-port"; + system = builtins.currentSystem; + builder = shell; + args = [ "-e" ./builder.sh ]; + setup = ./setup.sh; + LD_SCRIPT_SO = ./genode_rel.ld; + inherit initialPath; + }; + + setupHook = ./../setup-hooks.sh; + + system = builtins.currentSystem; + + builder = attrs.realBuilder or shell; + args = attrs.args or [ "-e" (attrs.builder or ./default-builder.sh) ]; +}) diff --git a/tool/prepare-port/genode_rel.ld b/tool/prepare-port/genode_rel.ld new file mode 100644 index 0000000..9b5add9 --- /dev/null +++ b/tool/prepare-port/genode_rel.ld @@ -0,0 +1,261 @@ +/* + * \brief Linker script for libraries + * \author Sebastian Sumpf + * \date 2009-11-05 + * + * Script for --shared -z combreloc: shared library, combine & sort relocs + */ + +/* + * Copyright (C) 2009-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. + */ + +PHDRS +{ + ro PT_LOAD; + rw PT_LOAD; + dynamic PT_DYNAMIC; + eh_frame PT_GNU_EH_FRAME; +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .note.gnu.build-id : { *(.note.gnu.build-id) } : ro + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } = 0x0 + .plt : { *(.plt) } + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } = 0x0 + .fini : + { + KEEP (*(.fini)) + } =0x0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + + .eh_frame_hdr : { *(.eh_frame_hdr) } : eh_frame : ro + .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) } + + /* + * Adjust the address for the data segment. We want to adjust up to + * the same address within the page on the next page up. + */ + . = ALIGN(0x1000); + + .data : + { + /* + * Leave space for parent capability parameters at start of data + * section. The protection domain creator is reponsible for storing + * sane values here. + */ + _parent_cap = .; + _parent_cap_thread_id = .; + LONG(0xffffffff); + _parent_cap_local_name = .; + LONG(0xffffffff); + LONG(0xffffffff); + LONG(0xffffffff); + LONG(0xffffffff); + LONG(0xffffffff); + LONG(0xffffffff); + LONG(0xffffffff); + + /* + * Platform-specific entry for Fiasco.OC. + * + * PIC-code compiled for Fiasco.OC, needs some PIC-compatible + * way to enter the kernel, the fixed address of the kernel + * entry code address needs to be found here. + */ + __l4sys_invoke_indirect = .; + LONG(0xeacff000); + + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } : rw + + /* .ARM.exidx is sorted, so has to go in its own output section */ + .ARM.extab : { + *(.ARM.extab*) + } + __exidx_start = .; + .ARM.exidx : { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } + __exidx_end = .; + + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .fini_array : + { + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + } + .ctors : + { + /* + * gcc uses crtbegin.o to find the start of the constructors, so we make + * sure it is first. Because this is a wildcard, it doesn't matter if the + * user does not actually link against crtbegin.o; the linker won't look + * for a file to match a wildcard. The wildcard also means that it + * doesn't matter which directory crtbegin.o is in. + * */ + /* KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors))*/ + /* + * We don't want to include the .ctor section from the crtend.o file until + * after the sorted ctors. The .ctor section from the crtend file contains + * the end of ctors marker and it must be last + */ + KEEP(*(_mark_ctors_start)); + _ctors_start = .; + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + KEEP (*(.init_array)) /* list of constructors specific for ARM eabi */ + _ctors_end = .; + KEEP(*(_mark_ctors_end)); + + } + .dtors : + { + PROVIDE(_dtors_start = .); + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + PROVIDE(_dtors_end = .); + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + + .data1 : { *(.data1) } + .dynamic : { *(.dynamic) } : dynamic : rw + /* See: genode_dyn.ld */ + .got : { *(.got.plt) *(.got) } + /* Exception handling */ + .eh_frame : + { + __eh_frame_start__ = .; + KEEP (*(.eh_frame)) + LONG(0) + } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + + /* + * Align here to ensure that the .bss section occupies space up to + * _end. Align after .bss to ensure correct alignment even if the + * .bss section disappears because there are no input sections. + * + * FIXME: Why do we need it? When there is no .bss section, we don't + * pad the .data section. + */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + _end = .; PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) } +} diff --git a/tool/prepare-port/setup.sh b/tool/prepare-port/setup.sh new file mode 100644 index 0000000..5dd63da --- /dev/null +++ b/tool/prepare-port/setup.sh @@ -0,0 +1,1264 @@ +set -eu +set -o pipefail + +if (( "${NIX_DEBUG:-0}" >= 6 )); then + set -x +fi + +: ${outputs:=out} + +if [ -n "${dev}" ]; then + export includedir=${dev}/include + export pkgconfigdir=${dev}/lib/pkgconfig +fi + +###################################################################### +# Hook handling. + + +# Run all hooks with the specified name in the order in which they +# were added, stopping if any fails (returns a non-zero exit +# code). The hooks for are the shell function or variable +# , and the values of the shell array ‘Hooks’. +runHook() { + local oldOpts="$(shopt -po nounset)" + set -u # May be called from elsewhere, so do `set -u`. + + local hookName="$1" + shift + local hooksSlice="${hookName%Hook}Hooks[@]" + + local hook + # Hack around old bash being bad and thinking empty arrays are + # undefined. + for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do + _eval "$hook" "$@" + set -u # To balance `_eval` + done + + eval "${oldOpts}" + return 0 +} + + +# Run all hooks with the specified name, until one succeeds (returns a +# zero exit code). If none succeed, return a non-zero exit code. +runOneHook() { + local oldOpts="$(shopt -po nounset)" + set -u # May be called from elsewhere, so do `set -u`. + + local hookName="$1" + shift + local hooksSlice="${hookName%Hook}Hooks[@]" + + local hook ret=1 + # Hack around old bash like above + for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; do + if _eval "$hook" "$@"; then + ret=0 + break + fi + set -u # To balance `_eval` + done + + eval "${oldOpts}" + return "$ret" +} + + +# Run the named hook, either by calling the function with that name or +# by evaluating the variable with that name. This allows convenient +# setting of hooks both from Nix expressions (as attributes / +# environment variables) and from shell scripts (as functions). If you +# want to allow multiple hooks, use runHook instead. +_callImplicitHook() { + set -u + local def="$1" + local hookName="$2" + case "$(type -t "$hookName")" in + (function|alias|builtin) + set +u + "$hookName";; + (file) + set +u + source "$hookName";; + (keyword) :;; + (*) if [ -z "${!hookName:-}" ]; then + return "$def"; + else + set +u + eval "${!hookName}" + fi;; + esac + # `_eval` expects hook to need nounset disable and leave it + # disabled anyways, so Ok to to delegate. The alternative of a + # return trap is no good because it would affect nested returns. +} + + +# A function wrapper around ‘eval’ that ensures that ‘return’ inside +# hooks exits the hook, not the caller. Also will only pass args if +# command can take them +_eval() { + if [ "$(type -t "$1")" = function ]; then + set +u + "$@" # including args + else + set +u + eval "$1" + fi + # `run*Hook` reenables `set -u` +} + + +###################################################################### +# Logging. + +# Obsolete. +stopNest() { true; } +header() { echo "$1"; } +closeNest() { true; } + +# Prints a command such that all word splits are unambiguous. We need +# to split the command in three parts because the middle format string +# will be, and must be, repeated for each argument. The first argument +# goes before the ':' and is just for convenience. +echoCmd() { + printf "%s:" "$1" + shift + printf ' %q' "$@" + echo +} + + +###################################################################### +# Error handling. + +exitHandler() { + exitCode="$?" + set +e + + if [ -n "${showBuildStats:-}" ]; then + times > "$NIX_BUILD_TOP/.times" + local -a times=($(cat "$NIX_BUILD_TOP/.times")) + # Print the following statistics: + # - user time for the shell + # - system time for the shell + # - user time for all child processes + # - system time for all child processes + echo "build time elapsed: " "${times[@]}" + fi + + if (( "$exitCode" != 0 )); then + runHook failureHook + + # If the builder had a non-zero exit code and + # $succeedOnFailure is set, create the file + # ‘$out/nix-support/failed’ to signal failure, and exit + # normally. Otherwise, return the original exit code. + if [ -n "${succeedOnFailure:-}" ]; then + echo "build failed with exit code $exitCode (ignored)" + mkdir -p "$out/nix-support" + printf "%s" "$exitCode" > "$out/nix-support/failed" + exit 0 + fi + + else + runHook exitHook + fi + + exit "$exitCode" +} + +trap "exitHandler" EXIT + + +###################################################################### +# Helper functions. + + +addToSearchPathWithCustomDelimiter() { + local delimiter="$1" + local varName="$2" + local dir="$3" + if [ -d "$dir" ]; then + export "${varName}=${!varName:+${!varName}${delimiter}}${dir}" + fi +} + +addToSearchPath() { + addToSearchPathWithCustomDelimiter ":" "$@" +} + +# Add $1/lib* into rpaths. +# The function is used in multiple-outputs.sh hook, +# so it is defined here but tried after the hook. +_addRpathPrefix() { + if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then + export NIX_LDFLAGS="-rpath $1/lib $NIX_LDFLAGS" + if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then + export NIX_LDFLAGS="-rpath $1/lib64 $NIX_LDFLAGS" + fi + if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then + export NIX_LDFLAGS="-rpath $1/lib32 $NIX_LDFLAGS" + fi + fi +} + +# Return success if the specified file is an ELF object. +isELF() { + local fn="$1" + local fd + local magic + exec {fd}< "$fn" + read -r -n 4 -u "$fd" magic + exec {fd}<&- + if [ "$magic" = $'\177ELF' ]; then return 0; else return 1; fi +} + +# Return success if the specified file is a script (i.e. starts with +# "#!"). +isScript() { + local fn="$1" + local fd + local magic + exec {fd}< "$fn" + read -r -n 2 -u "$fd" magic + exec {fd}<&- + if [[ "$magic" =~ \#! ]]; then return 0; else return 1; fi +} + +# printf unfortunately will print a trailing newline regardless +printLines() { + (( "$#" > 0 )) || return 0 + printf '%s\n' "$@" +} + +printWords() { + (( "$#" > 0 )) || return 0 + printf '%s ' "$@" +} + +###################################################################### +# Initialisation. + + +# Set a fallback default value for SOURCE_DATE_EPOCH, used by some +# build tools to provide a deterministic substitute for the "current" +# time. Note that 1 = 1970-01-01 00:00:01. We don't use 0 because it +# confuses some applications. +export SOURCE_DATE_EPOCH +: ${SOURCE_DATE_EPOCH:=1} + + +# Wildcard expansions that don't match should expand to an empty list. +# This ensures that, for instance, "for i in *; do ...; done" does the +# right thing. +shopt -s nullglob + + +# Set up the initial path. +PATH= +HOST_PATH= +for i in $initialPath; do + if [ "$i" = / ]; then i=; fi + addToSearchPath PATH "$i/bin" + + # For backward compatibility, we add initial path to HOST_PATH so + # it can be used in auto patch-shebangs. Unfortunately this will + # not work with cross compilation. + if [ -z "${strictDeps-}" ]; then + addToSearchPath HOST_PATH "$i/bin" + fi +done + +if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "initial path: $PATH" +fi + + +# Check that the pre-hook initialised SHELL. +if [ -z "${SHELL:-}" ]; then echo "SHELL not set"; exit 1; fi +BASH="$SHELL" +export CONFIG_SHELL="$SHELL" + + +# Execute the pre-hook. +if [ -z "${shell:-}" ]; then export shell="$SHELL"; fi +runHook preHook + + +# Allow the caller to augment buildInputs (it's not always possible to +# do this before the call to setup.sh, since the PATH is empty at that +# point; here we have a basic Unix environment). +runHook addInputsHook + + +# Package accumulators + +# shellcheck disable=SC2034 +declare -a pkgsBuildBuild pkgsBuildHost pkgsBuildTarget +declare -a pkgsHostHost pkgsHostTarget +declare -a pkgsTargetTarget + +declare -ra pkgBuildAccumVars=(pkgsBuildBuild pkgsBuildHost pkgsBuildTarget) +declare -ra pkgHostAccumVars=(pkgsHostHost pkgsHostTarget) +declare -ra pkgTargetAccumVars=(pkgsTargetTarget) + +declare -ra pkgAccumVarVars=(pkgBuildAccumVars pkgHostAccumVars pkgTargetAccumVars) + + +# Hooks + +declare -a envBuildBuildHooks envBuildHostHooks envBuildTargetHooks +declare -a envHostHostHooks envHostTargetHooks +declare -a envTargetTargetHooks + +declare -ra pkgBuildHookVars=(envBuildBuildHook envBuildHostHook envBuildTargetHook) +declare -ra pkgHostHookVars=(envHostHostHook envHostTargetHook) +declare -ra pkgTargetHookVars=(envTargetTargetHook) + +declare -ra pkgHookVarVars=(pkgBuildHookVars pkgHostHookVars pkgTargetHookVars) + +# Add env hooks for all sorts of deps with the specified host offset. +addEnvHooks() { + local depHostOffset="$1" + shift + local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]" + local pkgHookVar + for pkgHookVar in "${!pkgHookVarsSlice}"; do + eval "${pkgHookVar}s"'+=("$@")' + done +} + + +# Propagated dep files + +declare -ra propagatedBuildDepFiles=( + propagated-build-build-deps + propagated-native-build-inputs # Legacy name for back-compat + propagated-build-target-deps +) +declare -ra propagatedHostDepFiles=( + propagated-host-host-deps + propagated-build-inputs # Legacy name for back-compat +) +declare -ra propagatedTargetDepFiles=( + propagated-target-target-deps +) +declare -ra propagatedDepFilesVars=( + propagatedBuildDepFiles + propagatedHostDepFiles + propagatedTargetDepFiles +) + +# Platform offsets: build = -1, host = 0, target = 1 +declare -ra allPlatOffsets=(-1 0 1) + + +# Mutually-recursively find all build inputs. See the dependency section of the +# stdenv chapter of the Nixpkgs manual for the specification this algorithm +# implements. +findInputs() { + local -r pkg="$1" + local -ri hostOffset="$2" + local -ri targetOffset="$3" + + # Sanity check + (( "$hostOffset" <= "$targetOffset" )) || exit -1 + + local varVar="${pkgAccumVarVars[$hostOffset + 1]}" + local varRef="$varVar[\$targetOffset - \$hostOffset]" + local var="${!varRef}" + unset -v varVar varRef + + # TODO(@Ericson2314): Restore using associative array once Darwin + # nix-shell doesn't use impure bash. This should replace the O(n) + # case with an O(1) hash map lookup, assuming bash is implemented + # well :D. + local varSlice="$var[*]" + # ${..-} to hack around old bash empty array problem + case "${!varSlice-}" in + *" $pkg "*) return 0 ;; + esac + unset -v varSlice + + eval "$var"'+=("$pkg")' + + if ! [ -e "$pkg" ]; then + echo "build input $pkg does not exist" >&2 + exit 1 + fi + + # The current package's host and target offset together + # provide a <=-preserving homomorphism from the relative + # offsets to current offset + function mapOffset() { + local -ri inputOffset="$1" + if (( "$inputOffset" <= 0 )); then + local -ri outputOffset="$inputOffset + $hostOffset" + else + local -ri outputOffset="$inputOffset - 1 + $targetOffset" + fi + echo "$outputOffset" + } + + # Host offset relative to that of the package whose immediate + # dependencies we are currently exploring. + local -i relHostOffset + for relHostOffset in "${allPlatOffsets[@]}"; do + # `+ 1` so we start at 0 for valid index + local files="${propagatedDepFilesVars[$relHostOffset + 1]}" + + # Host offset relative to the package currently being + # built---as absolute an offset as will be used. + local -i hostOffsetNext + hostOffsetNext="$(mapOffset relHostOffset)" + + # Ensure we're in bounds relative to the package currently + # being built. + [[ "${allPlatOffsets[*]}" = *"$hostOffsetNext"* ]] || continue + + # Target offset relative to the *host* offset of the package + # whose immediate dependencies we are currently exploring. + local -i relTargetOffset + for relTargetOffset in "${allPlatOffsets[@]}"; do + (( "$relHostOffset" <= "$relTargetOffset" )) || continue + + local fileRef="${files}[$relTargetOffset - $relHostOffset]" + local file="${!fileRef}" + unset -v fileRef + + # Target offset relative to the package currently being + # built. + local -i targetOffsetNext + targetOffsetNext="$(mapOffset relTargetOffset)" + + # Once again, ensure we're in bounds relative to the + # package currently being built. + [[ "${allPlatOffsets[*]}" = *"$targetOffsetNext"* ]] || continue + + [[ -f "$pkg/nix-support/$file" ]] || continue + + local pkgNext + for pkgNext in $(< "$pkg/nix-support/$file"); do + findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext" + done + done + done +} + +# Make sure all are at least defined as empty +: ${depsBuildBuild=} ${depsBuildBuildPropagated=} +: ${nativeBuildInputs=} ${propagatedNativeBuildInputs=} ${defaultNativeBuildInputs=} +: ${depsBuildTarget=} ${depsBuildTargetPropagated=} +: ${depsHostHost=} ${depsHostHostPropagated=} +: ${buildInputs=} ${propagatedBuildInputs=} ${defaultBuildInputs=} +: ${depsTargetTarget=} ${depsTargetTargetPropagated=} + +for pkg in $depsBuildBuild $depsBuildBuildPropagated; do + findInputs "$pkg" -1 -1 +done +for pkg in $nativeBuildInputs $propagatedNativeBuildInputs; do + findInputs "$pkg" -1 0 +done +for pkg in $depsBuildTarget $depsBuildTargetPropagated; do + findInputs "$pkg" -1 1 +done +for pkg in $depsHostHost $depsHostHostPropagated; do + findInputs "$pkg" 0 0 +done +for pkg in $buildInputs $propagatedBuildInputs ; do + findInputs "$pkg" 0 1 +done +for pkg in $depsTargetTarget $depsTargetTargetPropagated; do + findInputs "$pkg" 1 1 +done +# Default inputs must be processed last +for pkg in $defaultNativeBuildInputs; do + findInputs "$pkg" -1 0 +done +for pkg in $defaultBuildInputs; do + findInputs "$pkg" 0 1 +done + +# Add package to the future PATH and run setup hooks +activatePackage() { + local pkg="$1" + local -ri hostOffset="$2" + local -ri targetOffset="$3" + + # Sanity check + (( "$hostOffset" <= "$targetOffset" )) || exit -1 + + if [ -f "$pkg" ]; then + local oldOpts="$(shopt -po nounset)" + set +u + source "$pkg" + eval "$oldOpts" + fi + + # Only dependencies whose host platform is guaranteed to match the + # build platform are included here. That would be `depsBuild*`, + # and legacy `nativeBuildInputs`, in general. If we aren't cross + # compiling, however, everything can be put on the PATH. To ease + # the transition, we do include everything in thatcase. + # + # TODO(@Ericson2314): Don't special-case native compilation + if [[ ( -z "${strictDeps-}" || "$hostOffset" -le -1 ) && -d "$pkg/bin" ]]; then + addToSearchPath _PATH "$pkg/bin" + fi + + if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then + addToSearchPath _HOST_PATH "$pkg/bin" + fi + + if [[ -f "$pkg/nix-support/setup-hook" ]]; then + local oldOpts="$(shopt -po nounset)" + set +u + source "$pkg/nix-support/setup-hook" + eval "$oldOpts" + fi +} + +_activatePkgs() { + local -i hostOffset targetOffset + local pkg + + for hostOffset in "${allPlatOffsets[@]}"; do + local pkgsVar="${pkgAccumVarVars[$hostOffset + 1]}" + for targetOffset in "${allPlatOffsets[@]}"; do + (( "$hostOffset" <= "$targetOffset" )) || continue + local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]" + local pkgsSlice="${!pkgsRef}[@]" + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do + activatePackage "$pkg" "$hostOffset" "$targetOffset" + done + done + done +} + +# Run the package setup hooks and build _PATH +_activatePkgs + +# Set the relevant environment variables to point to the build inputs +# found above. +# +# These `depOffset`s, beyond indexing the arrays, also tell the env +# hook what sort of dependency (ignoring propagatedness) is being +# passed to the env hook. In a real language, we'd append a closure +# with this information to the relevant env hook array, but bash +# doesn't have closures, so it's easier to just pass this in. +_addToEnv() { + local -i depHostOffset depTargetOffset + local pkg + + for depHostOffset in "${allPlatOffsets[@]}"; do + local hookVar="${pkgHookVarVars[$depHostOffset + 1]}" + local pkgsVar="${pkgAccumVarVars[$depHostOffset + 1]}" + for depTargetOffset in "${allPlatOffsets[@]}"; do + (( "$depHostOffset" <= "$depTargetOffset" )) || continue + local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]" + if [[ -z "${strictDeps-}" ]]; then + + # Keep track of which packages we have visited before. + local visitedPkgs="" + + # Apply environment hooks to all packages during native + # compilation to ease the transition. + # + # TODO(@Ericson2314): Don't special-case native compilation + for pkg in \ + ${pkgsBuildBuild+"${pkgsBuildBuild[@]}"} \ + ${pkgsBuildHost+"${pkgsBuildHost[@]}"} \ + ${pkgsBuildTarget+"${pkgsBuildTarget[@]}"} \ + ${pkgsHostHost+"${pkgsHostHost[@]}"} \ + ${pkgsHostTarget+"${pkgsHostTarget[@]}"} \ + ${pkgsTargetTarget+"${pkgsTargetTarget[@]}"} + do + if [[ "$visitedPkgs" = *"$pkg"* ]]; then + continue + fi + runHook "${!hookRef}" "$pkg" + visitedPkgs+=" $pkg" + done + else + local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]" + local pkgsSlice="${!pkgsRef}[@]" + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; do + runHook "${!hookRef}" "$pkg" + done + fi + done + done +} + +# Run the package-specific hooks set by the setup-hook scripts. +_addToEnv + + +# Set the TZ (timezone) environment variable, otherwise commands like +# `date' will complain (e.g., `Tue Mar 9 10:01:47 Local time zone must +# be set--see zic manual page 2004'). +export TZ=UTC + + +if [ "${useTempPrefix:-}" = 1 ]; then + prefix="$NIX_BUILD_TOP/tmp_prefix"; +fi + + +PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH" +HOST_PATH="${_HOST_PATH-}${_HOST_PATH:+${HOST_PATH:+:}}$HOST_PATH" +if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "final path: $PATH" + echo "final host path: $HOST_PATH" +fi + +unset _PATH +unset _HOST_PATH + + +# Make GNU Make produce nested output. +export NIX_INDENT_MAKE=1 + + +# Normalize the NIX_BUILD_CORES variable. The value might be 0, which +# means that we're supposed to try and auto-detect the number of +# available CPU cores at run-time. + +if [ -z "${NIX_BUILD_CORES:-}" ]; then + NIX_BUILD_CORES="1" +elif [ "$NIX_BUILD_CORES" -le 0 ]; then + NIX_BUILD_CORES=$(nproc 2>/dev/null || true) + if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then + : + else + NIX_BUILD_CORES="1" + fi +fi +export NIX_BUILD_CORES + + +# Prevent SSL libraries from using certificates in /etc/ssl, unless set explicitly. +# Leave it in impure shells for convenience. +if [ -z "${NIX_SSL_CERT_FILE:-}" ] && [ "${IN_NIX_SHELL:-}" != "impure" ]; then + export NIX_SSL_CERT_FILE=/no-cert-file.crt +fi +# Another variant left for compatibility. +if [ -z "${SSL_CERT_FILE:-}" ] && [ "${IN_NIX_SHELL:-}" != "impure" ]; then + export SSL_CERT_FILE=/no-cert-file.crt +fi + + +###################################################################### +# Textual substitution functions. + + +substituteStream() { + local var=$1 + local description=$2 + shift 2 + + while (( "$#" )); do + case "$1" in + --replace) + pattern="$2" + replacement="$3" + shift 3 + local savedvar + savedvar="${!var}" + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' + if [ "$pattern" != "$replacement" ]; then + if [ "${!var}" == "$savedvar" ]; then + echo "substituteStream(): WARNING: pattern '$pattern' doesn't match anything in $description" >&2 + fi + fi + ;; + + --subst-var) + local varName="$2" + shift 2 + # check if the used nix attribute name is a valid bash name + if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then + echo "substituteStream(): ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." >&2 + return 1 + fi + if [ -z ${!varName+x} ]; then + echo "substituteStream(): ERROR: variable \$$varName is unset" >&2 + return 1 + fi + pattern="@$varName@" + replacement="${!varName}" + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' + ;; + + --subst-var-by) + pattern="@$2@" + replacement="$3" + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' + shift 3 + ;; + + *) + echo "substituteStream(): ERROR: Invalid command line argument: $1" >&2 + return 1 + ;; + esac + done + + printf "%s" "${!var}" +} + +consumeEntire() { + # read returns non-0 on EOF, so we want read to fail + if IFS='' read -r -N 0 $1; then + echo "consumeEntire(): ERROR: Input null bytes, won't process" >&2 + return 1 + fi +} + +substitute() { + local input="$1" + local output="$2" + shift 2 + + if [ ! -f "$input" ]; then + echo "substitute(): ERROR: file '$input' does not exist" >&2 + return 1 + fi + + local content + consumeEntire content < "$input" + + if [ -e "$output" ]; then chmod +w "$output"; fi + substituteStream content "file '$input'" "$@" > "$output" +} + +substituteInPlace() { + local fileName="$1" + shift + substitute "$fileName" "$fileName" "$@" +} + +_allFlags() { + for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); do + if (( "${NIX_DEBUG:-0}" >= 1 )); then + printf "@%s@ -> %q\n" "${varName}" "${!varName}" + fi + args+=("--subst-var" "$varName") + done +} + +substituteAllStream() { + local -a args=() + _allFlags + + substituteStream "$1" "$2" "${args[@]}" +} + +# Substitute all environment variables that start with a lowercase character and +# are valid Bash names. +substituteAll() { + local input="$1" + local output="$2" + + local -a args=() + _allFlags + + substitute "$input" "$output" "${args[@]}" +} + + +substituteAllInPlace() { + local fileName="$1" + shift + substituteAll "$fileName" "$fileName" "$@" +} + + +###################################################################### +# Dev output functions. + + +compileStub() { + local ASM_SYM_DEPENDENCY="movq \1@GOTPCREL(%rip), %rax" + # TODO: .long \1 + + sed \ + -e "s/^\(\w\+\) D \(\w\+\)\$/.data; .global \1; .type \1,%object; .size \1,\2; \1:/p" \ + -e "s/^\(\w\+\) V/.data; .weak \1; .type \1,%object; \1:/p" \ + -e "s/^\(\w\+\) T/.text; .global \1; .type \1,%function; \1:/p" \ + -e "s/^\(\w\+\) R \(\w\+\)\$/.section .rodata; .global \1; .type \1,%object; .size \1,\2; \1:/p" \ + -e "s/^\(\w\+\) W/.text; .weak \1; .type \1,%function; \1:/p" \ + -e "s/^\(\w\+\) B \(\w\+\)\$/.bss; .global \1; .type \1,%object; .size \1,\2; \1:/p" \ + -e "s/^\(\w\+\) U/.text; .global \1; ${ASM_SYM_DEPENDENCY}/p" \ + $1 > symbols.s + + genode-x86-gcc -x assembler -c symbols.s -o tmp.o + + ld -o $2 \ + -shared \ + -T@LD_SCRIPT_SO@ \ + tmp.o + + rm tmp.o symbols.s +} + + +###################################################################### +# What follows is the generic builder. + + +# This function is useful for debugging broken Nix builds. It dumps +# all environment variables to a file `env-vars' in the build +# directory. If the build fails and the `-K' option is used, you can +# then go to the build directory and source in `env-vars' to reproduce +# the environment used for building. +dumpVars() { + if [ "${noDumpEnvVars:-0}" != 1 ]; then + export > "$NIX_BUILD_TOP/env-vars" || true + fi +} + + +# Utility function: echo the base name of the given path, with the +# prefix `HASH-' removed, if present. +stripHash() { + local strippedName + # On separate line for `set -e` + strippedName="$(basename "$1")" + if echo "$strippedName" | grep -q '^[a-z0-9]\{32\}-'; then + echo "$strippedName" | cut -c34- + else + echo "$strippedName" + fi +} + + +unpackCmdHooks+=(_defaultUnpack) +_defaultUnpack() { + local fn="$1" + + if [ -d "$fn" ]; then + + # We can't preserve hardlinks because they may have been + # introduced by store optimization, which might break things + # in the build. + cp -pr --reflink=auto -- "$fn" "$(stripHash "$fn")" + + else + + case "$fn" in + *.tar.xz | *.tar.lzma | *.txz) + # Don't rely on tar knowing about .xz. + xz -d < "$fn" | tar xf - ${tarFlags} + ;; + *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz) + # GNU tar can automatically select the decompression method + # (info "(tar) gzip"). + tar xf "$fn" ${tarFlags} + ;; + *) + return 1 + ;; + esac + + fi +} + + +unpackFile() { + curSrc="$1" + header "unpacking source archive $curSrc" 3 + if ! runOneHook unpackCmd "$curSrc"; then + echo "do not know how to unpack source archive $curSrc" + exit 1 + fi +} + + +unpackPhase() { + runHook preUnpack + + if [ -z "${srcs:-}" ]; then + if [ -z "${src:-}" ]; then + # shellcheck disable=SC2016 + echo 'variable $src or $srcs should point to the source' + exit 1 + fi + srcs="$src" + fi + + # To determine the source directory created by unpacking the + # source archives, we record the contents of the current + # directory, then look below which directory got added. Yeah, + # it's rather hacky. + local dirsBefore="" + for i in *; do + if [ -d "$i" ]; then + dirsBefore="$dirsBefore $i " + fi + done + + # Unpack all source archives. + for i in $srcs; do + unpackFile "$i" + done + + # Find the source directory. + + # set to empty if unset + : ${sourceRoot=} + + if [ -n "${setSourceRoot:-}" ]; then + runOneHook setSourceRoot + elif [ -z "$sourceRoot" ]; then + for i in *; do + if [ -d "$i" ]; then + case $dirsBefore in + *\ $i\ *) + ;; + *) + if [ -n "$sourceRoot" ]; then + echo "unpacker produced multiple directories" + exit 1 + fi + sourceRoot="$i" + ;; + esac + fi + done + fi + + if [ -z "$sourceRoot" ]; then + echo "unpacker appears to have produced no directories" + exit 1 + fi + + echo "source root is $sourceRoot" + + # By default, add write permission to the sources. This is often + # necessary when sources have been copied from other store + # locations. + if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then + chmod -R u+w -- "$sourceRoot" + fi + + runHook postUnpack +} + + +patchPhase() { + runHook prePatch + + for i in ${patches:-}; do + header "applying patch $i" 3 + local uncompress=cat + case "$i" in + *.gz) + uncompress="gzip -d" + ;; + *.bz2) + uncompress="bzip2 -d" + ;; + *.xz) + uncompress="xz -d" + ;; + *.lzma) + uncompress="lzma -d" + ;; + esac + # "2>&1" is a hack to make patch fail if the decompressor fails (nonexistent patch, etc.) + # shellcheck disable=SC2086 + $uncompress < "$i" 2>&1 | patch ${patchFlags:--p1} + done + + runHook postPatch +} + + +fixLibtool() { + sed -i -e 's^eval sys_lib_.*search_path=.*^^' "$1" +} + + +buildPhase() { + runHook preBuild + runHook postBuild +} + + +checkPhase() { + runHook preCheck + + if [[ -z "${foundMakefile:-}" ]]; then + echo "no Makefile or custom buildPhase, doing nothing" + runHook postCheck + return + fi + + if [[ -z "${checkTarget:-}" ]]; then + #TODO(@oxij): should flagsArray influence make -n? + if make -n ${makefile:+-f $makefile} check >/dev/null 2>&1; then + checkTarget=check + elif make -n ${makefile:+-f $makefile} test >/dev/null 2>&1; then + checkTarget=test + fi + fi + + if [[ -z "${checkTarget:-}" ]]; then + echo "no check/test target in ${makefile:-Makefile}, doing nothing" + else + # Old bash empty array hack + # shellcheck disable=SC2086 + local flagsArray=( + ${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} + SHELL=$SHELL + $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} + ${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"} + ${checkTarget} + ) + + echoCmd 'check flags' "${flagsArray[@]}" + make ${makefile:+-f $makefile} "${flagsArray[@]}" + + unset flagsArray + fi + + runHook postCheck +} + + +installPhase() { + runHook preInstall + + if [ -n "$source" ]; then + mkdir -p "$source" + fi + + cp -r ./* "$source" + + runHook postInstall +} + + +# The fixup phase performs generic, package-independent stuff, like +# stripping binaries, running patchelf and setting +# propagated-build-inputs. +fixupPhase() { + # Make sure everything is writable so "strip" et al. work. + local output + for output in $outputs; do + if [ -e "${!output}" ]; then chmod -R u+w "${!output}"; fi + done + + runHook preFixup + + # Apply fixup to each output. + local output + for output in $outputs; do + prefix="${!output}" runHook fixupOutput + done + + + # Propagate dependencies & setup hook into the development output. + declare -ra flatVars=( + # Build + depsBuildBuildPropagated + propagatedNativeBuildInputs + depsBuildTargetPropagated + # Host + depsHostHostPropagated + propagatedBuildInputs + # Target + depsTargetTargetPropagated + ) + declare -ra flatFiles=( + "${propagatedBuildDepFiles[@]}" + "${propagatedHostDepFiles[@]}" + "${propagatedTargetDepFiles[@]}" + ) + + local propagatedInputsIndex + for propagatedInputsIndex in "${!flatVars[@]}"; do + local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]" + local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}" + + [[ "${!propagatedInputsSlice}" ]] || continue + + mkdir -p "${dev}/nix-support" + # shellcheck disable=SC2086 + printWords ${!propagatedInputsSlice} > "${dev}/nix-support/$propagatedInputsFile" + done + + + if [ -n "${setupHook:-}" ]; then + mkdir -p "${dev}/nix-support" + substituteAll "$setupHook" "${dev}/nix-support/setup-hook" + fi + + # TODO(@Ericson2314): Remove after https://github.com/NixOS/nixpkgs/pull/31414 + if [ -n "${setupHooks:-}" ]; then + mkdir -p "${dev}/nix-support" + local hook + for hook in $setupHooks; do + local content + consumeEntire content < "$hook" + substituteAllStream content "file '$hook'" >> "${dev}/nix-support/setup-hook" + unset -v content + done + unset -v hook + fi + + # Propagate user-env packages into the output with binaries, TODO? + + if [ -n "${propagatedUserEnvPkgs:-}" ]; then + mkdir -p "${!outputBin}/nix-support" + # shellcheck disable=SC2086 + printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages" + fi + + set -v + + if [ -d "${dev}" ]; then + touch ${dev}/.genode + for pc in ${dev}/lib/pkgconfig/*.pc + do + sed -i "s|-l:|${dev}/lib/|g" $pc + done + fi + + runHook postFixup +} + + +installCheckPhase() { + runHook preInstallCheck + + if [[ -z "${foundMakefile:-}" ]]; then + echo "no Makefile or custom buildPhase, doing nothing" + #TODO(@oxij): should flagsArray influence make -n? + elif [[ -z "${installCheckTarget:-}" ]] \ + && ! make -n ${makefile:+-f $makefile} ${installCheckTarget:-installcheck} >/dev/null 2>&1; then + echo "no installcheck target in ${makefile:-Makefile}, doing nothing" + else + # Old bash empty array hack + # shellcheck disable=SC2086 + local flagsArray=( + ${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} + SHELL=$SHELL + $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} + $installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"} + ${installCheckTarget:-installcheck} + ) + + echoCmd 'installcheck flags' "${flagsArray[@]}" + make ${makefile:+-f $makefile} "${flagsArray[@]}" + unset flagsArray + fi + + runHook postInstallCheck +} + + +distPhase() { + runHook preDist + + # Old bash empty array hack + # shellcheck disable=SC2086 + local flagsArray=( + $distFlags ${distFlagsArray+"${distFlagsArray[@]}"} ${distTarget:-dist} + ) + + echo 'dist flags: %q' "${flagsArray[@]}" + make ${makefile:+-f $makefile} "${flagsArray[@]}" + + if [ "${dontCopyDist:-0}" != 1 ]; then + mkdir -p "$out/tarballs" + + # Note: don't quote $tarballs, since we explicitly permit + # wildcards in there. + # shellcheck disable=SC2086 + cp -pvd ${tarballs:-*.tar.gz} "$out/tarballs" + fi + + runHook postDist +} + + +showPhaseHeader() { + local phase="$1" + case "$phase" in + unpackPhase) header "unpacking sources";; + patchPhase) header "patching sources";; + configurePhase) header "configuring";; + buildPhase) header "building";; + checkPhase) header "running tests";; + installPhase) header "installing";; + fixupPhase) header "post-installation fixup";; + installCheckPhase) header "running install tests";; + *) header "$phase";; + esac +} + + +genericBuild() { + header "preparing $out" + + if [ -f "${buildCommandPath:-}" ]; then + local oldOpts="$(shopt -po nounset)" + set +u + source "$buildCommandPath" + eval "$oldOpts" + return + fi + if [ -n "${buildCommand:-}" ]; then + local oldOpts="$(shopt -po nounset)" + set +u + eval "$buildCommand" + eval "$oldOpts" + return + fi + + if [ -z "$phases" ]; then + phases="unpackPhase patchPhase buildPhase installPhase fixupPhase" + fi + + + for curPhase in $phases; do + if [[ -n $NIX_LOG_FD ]]; then + echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&$NIX_LOG_FD + fi + + showPhaseHeader "$curPhase" + dumpVars + + # Evaluate the variable named $curPhase if it exists, otherwise the + # function named $curPhase. + local oldOpts="$(shopt -po nounset)" + set +u + eval "${!curPhase:-$curPhase}" + eval "$oldOpts" + + if [ "$curPhase" = unpackPhase ]; then + cd "${sourceRoot:-.}" + fi + done +} + + +# Execute the post-hooks. +runHook postHook + + +# Execute the global user hook (defined through the Nixpkgs +# configuration option ‘stdenv.userHook’). This can be used to set +# global compiler optimisation flags, for instance. +runHook userHook + + +dumpVars + +# Disable nounset for nix-shell. +set +u diff --git a/tool/setup-hooks.sh b/tool/setup-hooks.sh new file mode 100644 index 0000000..b4d96c5 --- /dev/null +++ b/tool/setup-hooks.sh @@ -0,0 +1,7 @@ +addGenodePkgConfigPath () { + if test -e "$1/.genode" && test -d "$1/lib/pkgconfig"; then + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$1/lib/pkgconfig" + fi +} + +addEnvHooks "$targetOffset" addGenodePkgConfigPath diff --git a/tool/toolchain.nix b/tool/toolchain.nix new file mode 100644 index 0000000..f2acd76 --- /dev/null +++ b/tool/toolchain.nix @@ -0,0 +1,69 @@ +let + nixpkgs = import {}; + inherit (nixpkgs) buildPackages; + stdenv = nixpkgs.stdenvNoCC; + genodeVersion = "19.05"; + glibc = nixpkgs.stdenv.glibc; + glibcVersion = (builtins.parseDrvName glibc.name).version; +in +stdenv.mkDerivation rec { + name = "genode-toolchain-${genodeVersion}"; + version = genodeVersion; + + src = + if stdenv.isx86_64 then + nixpkgs.fetchurl { + url = "https://downloads.sourceforge.net/project/genode/genode-toolchain/${genodeVersion}/genode-toolchain-${genodeVersion}-x86_64.tar.xz"; + sha256 = "036czy21zk7fvz1y1p67q3d5hgg8rb8grwabgrvzgdsqcv2ls6l9"; + } + else abort "no toolchain for ${stdenv.system}"; + + depsBuildBuild = with buildPackages; [ patchelf ]; + + dontPatchELF = true; + + # installPhase is disabled for now + phases = "unpackPhase fixupPhase"; + + unpackPhase = '' + mkdir -p $out + + echo "unpacking $src..." + tar xf $src --strip-components=5 -C $out + ''; + + installPhase = '' + cd $out/bin + for platform in arm x86 ; do + dest="$"$platform"/bin" + eval dest=$"$dest" + + mkdir -p $dest + + for b in genode-$platform-* ; do + eval ln -s $b $dest/$\{b#genode-$platform-\} + done + + done + cd - + ''; + + fixupPhase = '' + interp=${glibc.out}/lib/ld-${glibcVersion}.so + if [ ! -f "$interp" ] ; then + echo new interpreter $interp does not exist, + echo cannot patch binaries + exit 1 + fi + + for f in $(find $out); do + if [ -f "$f" ] && patchelf "$f" 2> /dev/null; then + patchelf --set-interpreter $interp \ + --set-rpath $out/lib:${glibc.out}/lib:${buildPackages.zlib.out}/lib \ + "$f" || true + fi + done + ''; + + passthru = { libc = glibc; }; +} diff --git a/upstream/default.nix b/upstream/default.nix new file mode 100644 index 0000000..897a535 --- /dev/null +++ b/upstream/default.nix @@ -0,0 +1,73 @@ +{ nixpkgs, toolchain }: + +with builtins; + +nixpkgs.stdenvNoCC.mkDerivation { + name = "genode"; + outputs = [ "out" "dev" ]; + version = "19.07"; + + HOST_LIBC = toolchain.libc.dev; + + src = nixpkgs.fetchgit + { url = "git://depot.h4ck.me/srv/git/genode"; + rev = "edb117c13b0cde38ba66ffaaa19a798fbb6d044d"; + sha256 = "0rkpsh07hdv4r5pgyw707zhv546h96c6h150cdw01hi54jq8c0dr"; + fetchSubmodules = false; + }; + + setupHook = ./../tool/setup-hooks.sh; + + depsBuildBuild = with nixpkgs.buildPackages; + [ toolchain + stdenv.glibc.dev + git tup + pkgconfig + ]; + + configurePhase = + '' + # Populate the SDK headers + mkdir -p $out $dev/include + cp -r repos/base/src/ld $dev/ld + cp -r repos/base/include $dev/include/base + cp -r repos/os/include $dev/include/os + cp -r repos/libports/include $dev/include/libports + cp -r repos/gems/include $dev/include/gems + + # Configure Tup + echo CONFIG_NIX= >> tup.config + echo CONFIG_NIX_OUTPUTS_OUT=$out >> tup.config + echo CONFIG_NIX_OUTPUTS_DEV=$dev >> tup.config + + # Scan repository and generate script + rm Tupfile # skip the dhall stuff + tup init + tup generate buildPhase.sh + + # Redirect artifacts to Nix store + ln -s $out out + ln -s $dev dev + ''; + + buildPhase = + '' + source buildPhase.sh + ''; + + installPhase = + '' + touch $dev/.genode + for pc in $dev/lib/pkgconfig/*.pc + do + sed -i "s|-l:|$dev/lib/|g" $pc + done + ''; + + shellHook = + '' + export PROMPT_DIRTRIM=2 + export PS1="\[\033[1;30m\]Genode-dev [\[\033[1;37m\]\w\[\033[1;30m\]] $\[\033[0m\] " + export PS2="\[\033[1;30m\]>\[\033[0m\] " + ''; +}