NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.44k stars 13.64k forks source link

wrong MacOS sdk version is detect #131723

Open yaitskov opened 3 years ago

yaitskov commented 3 years ago

Hi,

I am trying to build pyobjc binding. A builder detects 10.15 but clang gets header files for 10.12, because new protocols are used from 10.13 - build fails.

-isysroot is ignored by clang (don't no why), but it affects sdk version detection! my workaround is to specify -isysroot a fake path with 10.12 instead of 10.15.

I run Big Sur VM on AWS.

default.nix file:

{ pkgs ? import <nixpkgs> {} }:
  let
    pyobjc = pkgs.python39Packages.buildPythonPackage rec {
      pname = "pyobjc";
      version = "7.3";
      name = "${pname}-${version}";
      src = pkgs.python39Packages.fetchPypi {
        pname = "pyobjc-framework-Cocoa";
        inherit version;
        sha256 = "0zhbp18i06aprwfbp06l9wm3qrzsdcyy9hwis5d4b8wmlzkhb3di"; # 7.3 Cocoa                     
      };
      CFLAGS="-Wno-unused-argument";
      # workaround
      # CFLAGS="-Wno-unused-argument -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk";

      doCheck = false;
      propagatedBuildInputs = [
        pkgs.darwin.libobjc
        pkgs.darwin.apple_sdk.frameworks.Foundation
        pkgs.darwin.apple_sdk.frameworks.CoreFoundation
        pkgs.darwin.apple_sdk.frameworks.AVKit
    pkgs.darwin.apple_sdk.frameworks.AppKit
    pkgs.darwin.apple_sdk.frameworks.DVDPlayback
    pkgs.darwin.apple_sdk.frameworks.CoreServices
        pkgs.darwin.apple_sdk.frameworks.Accounts
        pkgs.darwin.apple_sdk.frameworks.IMServicePlugIn
        # pkgs.darwin.apple_sdk.frameworks.CryptoTokenKit                                                
        # pkgs.darwin.apple_sdk.frameworks.Security                                                      
        # pkgs.darwin.apple_sdk.frameworks.CoreHaptics                                                   
        pkgs.python39Packages.setuptools
      ];
    };
    foo = pkgs.stdenv.mkDerivation rec {
      pname = "foo";
      version = "0.1";
      src = ./.;
      buildInputs = [ pyobjc ];
      # pkgs.clang pkgs.darwin.libobjc pkgs.darwin.apple_sdk.frameworks.Foundation ];                    
    };
  in foo
nix-shell

clang -Wno-unused-argument -I/nix/store/096xl1vmxg7hn19pj8s624rpc7h4gdyp-python3-3.9.4/include/python3.9\
 -c Modules/_Foundation.m -o build/temp.macosx-10.6-x86_64-3.9/Modules/_Foundation.o -Wno-deprecated-dec\
larations -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -DPyObjC_BUILD_RELEASE=1103 -Wer\
ror
In file included from Modules/_Foundation.m:14:
Modules/_Foundation_protocols.m:101:28: error: cannot find protocol declaration for 'NSItemProviderWriti\
ng'
    p = PyObjC_IdToPython(@protocol(NSItemProviderWriting));

protocol NSItemProviderWriting appears in SDK 10.13 but headers are for 10.12.

yaitskov commented 3 years ago

Another miner issue but also related to version detection. Output directory contains another sdk version not equal to 10.12 nor 10.13 but 10.6!:

clang -Wno-unused-argument -I/nix/store/096xl1vmxg7hn19pj8s624rpc7h4gdyp-python3-3.9.4/include/python3.9\
 -c Modules/_Foundation_inlines.m -o build/temp.macosx-10.6-x86_64-3.9/Modules/_Foundation_inlines.o

It doesn't break anything but looks weird. It must be in sync with version used for building. I was not able to grep location where -o <path> is generate to trace further.

When I run python3 setup.py build without nix I get a correct version of sdk there. So this is unlikely a pyobjc bug.

yaitskov commented 3 years ago

Oh my workaround is working only for pyobjc-framework-Cocoa module but not for pobjc-core :(

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info