gfx-rs / portability

Vulkan Portability Implementation
Mozilla Public License 2.0
384 stars 25 forks source link

Make portability compatible with XCode 10 command line tools.. #159

Closed oscarbg closed 6 years ago

oscarbg commented 6 years ago

Hi finally tried to build by myself and I get an error..

any clue?

cargo build --manifest-path libportability/Cargo.toml --features metal
   Compiling gfx-backend-metal v0.1.0 (https://github.com/gfx-rs/gfx#5f9f5237)
   Compiling objc_id v0.1.1
   Compiling cocoa v0.17.0
   Compiling cocoa v0.18.0
   Compiling objc-foundation v0.1.1
error: failed to run custom build command for `gfx-backend-metal v0.1.0 (https://github.com/gfx-rs/gfx#5f9f5237)`
process didn't exit successfully: `/Volumes/sierr6/Users/oscar/sep/portability/target/debug/build/gfx-backend-metal-f3b1debd56e7eb5a/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=/Users/oscar/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/5f9f523/src/backend/metal/shaders
cargo:rerun-if-changed=/Users/oscar/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/5f9f523/src/backend/metal/shaders/blit.metal
cargo:rerun-if-changed=/Users/oscar/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/5f9f523/src/backend/metal/shaders/macros.metal
cargo:rerun-if-changed=/Users/oscar/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/5f9f523/src/backend/metal/shaders/fill.metal
cargo:rerun-if-changed=/Users/oscar/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/5f9f523/src/backend/metal/shaders/clear.metal

--- stderr
metallib: Invalid bitcode file!
thread 'main' panicked at 'shader library build failed', /Users/oscar/.cargo/git/checkouts/gfx-e86e7f3ebdbc4218/5f9f523/src/backend/metal/build.rs:83:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
             at libstd/panicking.rs:511
   5: std::panicking::begin_panic
             at /Users/travis/build/rust-lang/rust/src/libstd/panicking.rs:445
   6: build_script_build::main
             at ./build.rs:83
   7: std::rt::lang_start::{{closure}}
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
   8: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
   9: panic_unwind::dwarf::eh::read_encoded_pointer
             at libpanic_unwind/lib.rs:105
  10: std::sys_common::at_exit_imp::push
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  11: std::rt::lang_start
             at /Users/travis/build/rust-lang/rust/src/libstd/rt.rs:74
  12: build_script_build::main::{{closure}}

warning: build failed, waiting for other jobs to finish...
error: build failed
oscarbg commented 6 years ago

Hi, maybe it's because I'm using Xcode 10 beta? expected to work on Xcode 9 latest build? thanks..

kvark commented 6 years ago

@oscarbg we currently require the command line tools from XCode 9, while we do actual debugging in XCode 10 (like GPU capturing). You can change the default toolset by going to XCode (menu) -> Preferences -> Locations (tab) -> Command Line Tools.

As for this issue, we can either close it, or rename to - make portability compatible with XCode 10 command line tools, which would be useful for sure, but nobody has looked at what needs to be done there yet.

oscarbg commented 6 years ago

@kvark thanks.. just renamed issue title, as Xcode 10 will become out of beta this month and more people might find same issue..

oscarbg commented 6 years ago

@kvark I think the problem with Xcode 10 tools: metallib: Invalid bitcode file! is due to now "metal" command needing now an added "-c" argument see here how they fixed also the same error I was having also with Xcode 10: https://github.com/ConfettiFX/The-Forge/issues/64 EDIT: also installed Xcode 9.4.1 command line tools and pointed to it with Xcode-select: /Library/Developer/CommandLineTools but then the problem is metal command isn't found there so can't be solved with Xcode 9 command tools you need full Xcode 9..

so the fix seems in gfx/src/backend/metal/build.rs

let status = Command::new("xcrun")
            .args(&["-sdk", sdk_name, "metal"])
            .arg(shader_path.as_os_str())

for:

let status = Command::new("xcrun")
            .args(&["-sdk", sdk_name, "metal"])
            .arg("-c")
            .arg(shader_path.as_os_str())

EDIT: confirmed this is enough to build the library!

kvark commented 6 years ago

Fixed by https://github.com/gfx-rs/gfx/pull/2379 will close once we update to this gfx-rs version

kvark commented 6 years ago

Fixed by https://github.com/gfx-rs/portability/pull/162