diff options
Diffstat (limited to 'pkgs/development/interpreters')
7 files changed, 257 insertions, 5 deletions
diff --git a/pkgs/development/interpreters/proglodyte-wasm/default.nix b/pkgs/development/interpreters/proglodyte-wasm/default.nix index 8ebbf6cf5012..3569f66aed0a 100644 --- a/pkgs/development/interpreters/proglodyte-wasm/default.nix +++ b/pkgs/development/interpreters/proglodyte-wasm/default.nix @@ -14,7 +14,8 @@ let # set this to nonempty string to disable default cmake configure ''; - buildInputs = [ cmake clang python ]; + nativeBuildInputs = [ cmake ]; + buildInputs = [ clang python ]; buildPhase = "make clang-debug-no-tests"; diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index e6ab1f218795..4c0501aebcd2 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -114,6 +114,9 @@ let # libuuid, slowing down program startup a lot). ./no-ldconfig.patch + # Fix ctypes.util.find_library with gcc10. + ./find_library-gcc10.patch + ] ++ optionals stdenv.hostPlatform.isCygwin [ ./2.5.2-ctypes-util-find_library.patch ./2.5.2-tkinter-x11.patch diff --git a/pkgs/development/interpreters/python/cpython/2.7/find_library-gcc10.patch b/pkgs/development/interpreters/python/cpython/2.7/find_library-gcc10.patch new file mode 100644 index 000000000000..4627baf119c1 --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/2.7/find_library-gcc10.patch @@ -0,0 +1,79 @@ +Backport https://github.com/python/cpython/commit/82df3b3071bb003247c33eac4670775e9883c994 +and https://github.com/python/cpython/commit/27ac19cca2c639caaf6fedf3632fe6beb265f24f + +Fixes the check phase of python2Packages.cffi. + +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -87,6 +87,12 @@ elif os.name == "posix": + # Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump + import re, tempfile, errno + ++ def _is_elf(filename): ++ "Return True if the given file is an ELF file" ++ elf_header = b'\x7fELF' ++ with open(filename, 'rb') as thefile: ++ return thefile.read(4) == elf_header ++ + def _findLib_gcc(name): + # Run GCC's linker with the -t (aka --trace) option and examine the + # library name it prints out. The GCC command will fail because we +@@ -110,10 +116,17 @@ elif os.name == "posix": + # the normal behaviour of GCC if linking fails + if e.errno != errno.ENOENT: + raise +- res = re.search(expr, trace) ++ res = re.findall(expr, trace) + if not res: + return None +- return res.group(0) ++ ++ for file in res: ++ # Check if the given file is an elf file: gcc can report ++ # some files that are linker scripts and not actual ++ # shared objects. See bpo-41976 for more details ++ if not _is_elf(file): ++ continue ++ return file + + + if sys.platform == "sunos5": +@@ -237,8 +250,37 @@ elif os.name == "posix": + def _findSoname_ldconfig(name): + return None + ++ def _findLib_ld(name): ++ # See issue #9998 for why this is needed ++ expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) ++ cmd = ['ld', '-t'] ++ libpath = os.environ.get('LD_LIBRARY_PATH') ++ if libpath: ++ for d in libpath.split(':'): ++ cmd.extend(['-L', d]) ++ cmd.extend(['-o', os.devnull, '-l%s' % name]) ++ result = None ++ try: ++ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ universal_newlines=True) ++ out, _ = p.communicate() ++ res = re.findall(expr, out) ++ for file in res: ++ # Check if the given file is an elf file: gcc can report ++ # some files that are linker scripts and not actual ++ # shared objects. See bpo-41976 for more details ++ if not _is_elf(file): ++ continue ++ return file ++ except Exception: ++ pass # result will be None ++ return result ++ + def find_library(name): +- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) ++ # See issue #9998 ++ return _findSoname_ldconfig(name) or \ ++ _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name)) + + ################################################################ + # test code diff --git a/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch b/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch new file mode 100644 index 000000000000..d324d10b39fc --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.6/fix-finding-headers-when-cross-compiling.patch @@ -0,0 +1,54 @@ +From 45dfbbb4f5b67ab83e4365564ea569334e979f8e Mon Sep 17 00:00:00 2001 +From: Ben Wolsieffer <benwolsieffer@gmail.com> +Date: Fri, 25 Sep 2020 16:49:16 -0400 +Subject: [PATCH] Fix finding headers when cross compiling + +When cross-compiling third-party extensions, get_python_inc() may be called to +return the path to Python's headers. However, it uses the sys.prefix or +sys.exec_prefix of the build Python, which returns incorrect paths when +cross-compiling (paths pointing to build system headers). + +To fix this, we use the INCLUDEPY and CONFINCLUDEPY conf variables, which can +be configured to point at host Python by setting _PYTHON_SYSCONFIGDATA_NAME. +The existing behavior is maintained on non-POSIX platforms or if a prefix is +manually specified. +--- + Lib/distutils/sysconfig.py | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py +index 2bcd1dd288..567375e488 100644 +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -84,8 +84,6 @@ def get_python_inc(plat_specific=0, prefix=None): + If 'prefix' is supplied, use it instead of sys.base_prefix or + sys.base_exec_prefix -- i.e., ignore 'plat_specific'. + """ +- if prefix is None: +- prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX + if os.name == "posix": + if python_build: + # Assume the executable is in the build directory. The +@@ -98,9 +96,17 @@ def get_python_inc(plat_specific=0, prefix=None): + else: + incdir = os.path.join(get_config_var('srcdir'), 'Include') + return os.path.normpath(incdir) +- python_dir = 'python' + get_python_version() + build_flags +- return os.path.join(prefix, "include", python_dir) ++ if prefix is None: ++ if plat_specific: ++ return get_config_var('CONFINCLUDEPY') ++ else: ++ return get_config_var('INCLUDEPY') ++ else: ++ python_dir = 'python' + get_python_version() + build_flags ++ return os.path.join(prefix, "include", python_dir) + elif os.name == "nt": ++ if prefix is None: ++ prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX + return os.path.join(prefix, "include") + else: + raise DistutilsPlatformError( +-- +2.28.0 + diff --git a/pkgs/development/interpreters/python/cpython/3.7/fix-finding-headers-when-cross-compiling.patch b/pkgs/development/interpreters/python/cpython/3.7/fix-finding-headers-when-cross-compiling.patch new file mode 100644 index 000000000000..543e267e94bf --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.7/fix-finding-headers-when-cross-compiling.patch @@ -0,0 +1,54 @@ +From debccd4be0a8d619770f63622d9de1b451dd02ac Mon Sep 17 00:00:00 2001 +From: Ben Wolsieffer <benwolsieffer@gmail.com> +Date: Fri, 25 Sep 2020 16:49:16 -0400 +Subject: [PATCH] Fix finding headers when cross compiling + +When cross-compiling third-party extensions, get_python_inc() may be called to +return the path to Python's headers. However, it uses the sys.prefix or +sys.exec_prefix of the build Python, which returns incorrect paths when +cross-compiling (paths pointing to build system headers). + +To fix this, we use the INCLUDEPY and CONFINCLUDEPY conf variables, which can +be configured to point at host Python by setting _PYTHON_SYSCONFIGDATA_NAME. +The existing behavior is maintained on non-POSIX platforms or if a prefix is +manually specified. +--- + Lib/distutils/sysconfig.py | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py +index 37feae5df7..6d4ad06696 100644 +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -95,8 +95,6 @@ def get_python_inc(plat_specific=0, prefix=None): + If 'prefix' is supplied, use it instead of sys.base_prefix or + sys.base_exec_prefix -- i.e., ignore 'plat_specific'. + """ +- if prefix is None: +- prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX + if os.name == "posix": + if python_build: + # Assume the executable is in the build directory. The +@@ -109,9 +107,17 @@ def get_python_inc(plat_specific=0, prefix=None): + else: + incdir = os.path.join(get_config_var('srcdir'), 'Include') + return os.path.normpath(incdir) +- python_dir = 'python' + get_python_version() + build_flags +- return os.path.join(prefix, "include", python_dir) ++ if prefix is None: ++ if plat_specific: ++ return get_config_var('CONFINCLUDEPY') ++ else: ++ return get_config_var('INCLUDEPY') ++ else: ++ python_dir = 'python' + get_python_version() + build_flags ++ return os.path.join(prefix, "include", python_dir) + elif os.name == "nt": ++ if prefix is None: ++ prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX + if python_build: + # Include both the include and PC dir to ensure we can find + # pyconfig.h +-- +2.28.0 + diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index b9f1820df3e8..525ef8c1c6d9 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -100,6 +100,50 @@ let "$out/bin/python" else pythonForBuild.interpreter; + # The CPython interpreter contains a _sysconfigdata_<platform specific suffix> + # module that is imported by the sysconfig and distutils.sysconfig modules. + # The sysconfigdata module is generated at build time and contains settings + # required for building Python extension modules, such as include paths and + # other compiler flags. By default, the sysconfigdata module is loaded from + # the currently running interpreter (ie. the build platform interpreter), but + # when cross-compiling we want to load it from the host platform interpreter. + # This can be done using the _PYTHON_SYSCONFIGDATA_NAME environment variable. + # The _PYTHON_HOST_PLATFORM variable also needs to be set to get the correct + # platform suffix on extension modules. The correct values for these variables + # are not documented, and must be derived from the configure script (see links + # below). + sysconfigdataHook = with stdenv.hostPlatform; with passthru; let + # https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L428 + # The configure script uses "arm" as the CPU name for all 32-bit ARM + # variants when cross-compiling, but native builds include the version + # suffix, so we do the same. + pythonHostPlatform = "${parsed.kernel.name}-${parsed.cpu.name}"; + + # https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L724 + multiarchCpu = + if isAarch32 then + if parsed.cpu.significantByte.name == "littleEndian" then "arm" else "armeb" + else if isx86_32 then "i386" + else parsed.cpu.name; + multiarch = + if isDarwin then "darwin" + else "${multiarchCpu}-${parsed.kernel.name}-${parsed.abi.name}"; + + abiFlags = optionalString (isPy36 || isPy37) "m"; + + # https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L78 + pythonSysconfigdataName = "_sysconfigdata_${abiFlags}_${parsed.kernel.name}_${multiarch}"; + in '' + sysconfigdataHook() { + if [ "$1" = '${placeholder "out"}' ]; then + export _PYTHON_HOST_PLATFORM='${pythonHostPlatform}' + export _PYTHON_SYSCONFIGDATA_NAME='${pythonSysconfigdataName}' + fi + } + + addEnvHooks "$hostOffset" sysconfigdataHook + ''; + in with passthru; stdenv.mkDerivation { pname = "python3"; inherit version; @@ -165,6 +209,13 @@ in with passthru; stdenv.mkDerivation { ] ++ [ # LDSHARED now uses $CC instead of gcc. Fixes cross-compilation of extension modules. ./3.8/0001-On-all-posix-systems-not-just-Darwin-set-LDSHARED-if.patch + # Use sysconfigdata to find headers. Fixes cross-compilation of extension modules. + ( + if isPy36 then + ./3.6/fix-finding-headers-when-cross-compiling.patch + else + ./3.7/fix-finding-headers-when-cross-compiling.patch + ) ] ++ optionals (isPy37 || isPy38) [ # Backport a fix for ctypes.util.find_library. ./3.7/find_library.patch @@ -281,6 +332,10 @@ in with passthru; stdenv.mkDerivation { find $out/lib/python*/config-* -type f -print -exec nuke-refs -e $out '{}' + find $out/lib -name '_sysconfigdata*.py*' -print -exec nuke-refs -e $out '{}' + + # Make the sysconfigdata module accessible on PYTHONPATH + # This allows build Python to import host Python's sysconfigdata + mkdir -p "$out/${sitePackages}" + ln -s "$out/lib/${libPrefix}/"_sysconfigdata*.py "$out/${sitePackages}/" '' + optionalString stripConfig '' rm -R $out/bin/python*-config $out/lib/python*/config-* '' + optionalString stripIdlelib '' @@ -313,6 +368,14 @@ in with passthru; stdenv.mkDerivation { export PATH=${stdenv.lib.makeBinPath [ "$out" bash ]}:$PATH ''; + # Add CPython specific setup-hook that configures distutils.sysconfig to + # always load sysconfigdata from host Python. + postFixup = stdenv.lib.optionalString (!stdenv.hostPlatform.isDarwin) '' + cat << "EOF" >> "$out/nix-support/setup-hook" + ${sysconfigdataHook} + EOF + ''; + # Enforce that we don't have references to the OpenSSL -dev package, which we # explicitly specify in our configure flags above. disallowedReferences = diff --git a/pkgs/development/interpreters/supercollider/default.nix b/pkgs/development/interpreters/supercollider/default.nix index acdffba8d72b..113eb54a00ba 100644 --- a/pkgs/development/interpreters/supercollider/default.nix +++ b/pkgs/development/interpreters/supercollider/default.nix @@ -1,4 +1,4 @@ -{ stdenv, mkDerivation, fetchurl, cmake, pkgconfig, alsaLib +{ stdenv, fetchurl, cmake, pkgconfig, alsaLib , libjack2, libsndfile, fftw, curl, gcc , libXt, qtbase, qttools, qtwebengine , readline, qtwebsockets, useSCEL ? false, emacs @@ -7,7 +7,7 @@ let optional = stdenv.lib.optional; in -mkDerivation rec { +stdenv.mkDerivation rec { pname = "supercollider"; version = "3.11.2"; @@ -26,8 +26,6 @@ mkDerivation rec { nativeBuildInputs = [ cmake pkgconfig qttools ]; - enableParallelBuilding = true; - buildInputs = [ gcc libjack2 libsndfile fftw curl libXt qtbase qtwebengine qtwebsockets readline ] ++ optional (!stdenv.isDarwin) alsaLib |