cc-rs: Compilation in a macOS GitHub runner fails with cc v1.0.84

Hello!

For my crate opencv I see that starting with cc version 1.0.84 the macOS runners are failing: https://github.com/twistedfall/opencv-rust/actions/runs/6853515550

I must also note that I haven’t used cc versions 1.0.80..=1.0.83 because of the another issue that was causing hangs due to the interaction of jobserver in both cc and opencv (https://github.com/rust-lang/cc-rs/issues/844)

The specific error is:

fatal error: 'limits' file not found

it is caused by the missing stdlib which clang warns about too:

clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]

As far as I can see between version 1.0.79 and 1.0.84 the C++ compiler is called with different arguments:

  • 1.0.79
"c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "-arch" "x86_64" "-I" "/Users/runner/work/opencv-rust/opencv-rust/src_cpp" "-I" "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-fb8aea6a002a5c33/out" "-I" "." "-I" "/usr/local/opt/opencv/include/opencv4" "-Wall" "-Wextra" "-std=c++14" "-Wno-deprecated-declarations" "-Wno-deprecated-copy" "-Wno-unused-parameter" "-Wno-sign-compare" "-Wno-comment" "-Wno-unused-variable" "-Wno-ignored-qualifiers" "-Wno-return-type-c-linkage" "-Wno-overloaded-virtual" "-F/usr/local/opt/opencv/include/opencv4" "-o" "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-fb8aea6a002a5c33/out/d25e1c8da0c38997-core.o" "-c" "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-fb8aea6a002a5c33/out/core.cpp"
  • 1.0.84
"c++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "--target=x86_64-apple-darwin" "-mmacosx-version-min=10.7" "-I" "/Users/runner/work/opencv-rust/opencv-rust/src_cpp" "-I" "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-80956898113978e8/out" "-I" "." "-I" "/usr/local/opt/opencv/include/opencv4" "-Wall" "-Wextra" "-std=c++14" "-o" "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-80956898113978e8/out/02e9e909b56518ad-core.o" "-c" "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-80956898113978e8/out/core.cpp"

The main differences I see is the -arch, --target, -mmacosx-version-min and a bunch of -W flags. The compiler identity looks different too:

  • 1.0.79 identifiers as Gnu
=== Compiler information: Tool {
    path: "c++",
    cc_wrapper_path: None,
    cc_wrapper_args: [],
    args: [
        "-O0",
        "-ffunction-sections",
        "-fdata-sections",
        "-fPIC",
        "-gdwarf-2",
        "-fno-omit-frame-pointer",
        "-m64",
        "-arch",
        "x86_64",
        "-I",
        "/Users/runner/work/opencv-rust/opencv-rust/src_cpp",
        "-I",
        "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-fb8aea6a002a5c33/out",
        "-I",
        ".",
        "-I",
        "/usr/local/opt/opencv/include/opencv4",
        "-Wall",
        "-Wextra",
        "-std=c++14",
        "-Wno-deprecated-declarations",
        "-Wno-deprecated-copy",
        "-Wno-unused-parameter",
        "-Wno-sign-compare",
        "-Wno-comment",
        "-Wno-unused-variable",
        "-Wno-ignored-qualifiers",
        "-Wno-return-type-c-linkage",
        "-Wno-overloaded-virtual",
        "-F/usr/local/opt/opencv/include/opencv4",
    ],
    env: [],
    family: Gnu,
    cuda: false,
    removed_args: [],
}
  • 1.0.84 identifies as Clang:
=== Compiler information: Tool {
    path: "c++",
    cc_wrapper_path: None,
    cc_wrapper_args: [],
    args: [
        "-O0",
        "-ffunction-sections",
        "-fdata-sections",
        "-fPIC",
        "-gdwarf-2",
        "-fno-omit-frame-pointer",
        "-m64",
        "--target=x86_64-apple-darwin",
        "-mmacosx-version-min=10.7",
        "-I",
        "/Users/runner/work/opencv-rust/opencv-rust/src_cpp",
        "-I",
        "/Users/runner/work/opencv-rust/opencv-rust/target/debug/build/opencv-80956898113978e8/out",
        "-I",
        ".",
        "-I",
        "/usr/local/opt/opencv/include/opencv4",
        "-Wall",
        "-Wextra",
        "-std=c++14",
    ],
    env: [],
    family: Clang,
    cuda: false,
    removed_args: [],
    has_internal_target_arg: false,
}

The compiler is created as follows in opencv code: https://github.com/twistedfall/opencv-rust/blob/730cc64955ab4ad5286bee891e795a1322b053c0/build.rs#L223-L276

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 1
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I mentioned this to @NobodyXu in a Zulip DM but I will be opening a PR shortly to revert the specific behavior change of querying rustc for the default version if nothing is supplied instead of using the SDKs’ DefaultDeploymentTarget. I’ll try and have that up tonight for review. This will bring most people back to the behavior before while still allowing people to use MACOSX_DEPLOYMENT_TARGET if they do set it.