Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Will not compile with homebrew's GCC. #12

Open
nobuyuki opened this issue Jul 2, 2022 · 0 comments
Open

Will not compile with homebrew's GCC. #12

nobuyuki opened this issue Jul 2, 2022 · 0 comments

Comments

@nobuyuki
Copy link

nobuyuki commented Jul 2, 2022

Hi,

I found that this crate does not compile with homebrew's GCC. ( Fine with macos's cc).

➜  rust-objc-exception git:(master) cargo build
    Updating crates.io index
   Compiling cc v1.0.73
   Compiling objc_exception v0.1.2 (/Users/nobuyuki.tomizawa/tmp/rust-objc-exception)
The following warnings were emitted during compilation:

warning: extern/exception.m: In function 'RustObjCExceptionThrow':
warning: extern/exception.m:5:5: error: '-fobjc-exceptions' is required to enable Objective-C exception syntax
warning:     5 |     @throw exception;
warning:       |     ^~~~~~
warning: extern/exception.m:4:32: warning: parameter 'exception' set but not used [-Wunused-but-set-parameter]
warning:     4 | void RustObjCExceptionThrow(id exception) {
warning:       |                             ~~~^~~~~~~~~

error: failed to run custom build command for `objc_exception v0.1.2 (/Users/nobuyuki.tomizawa/tmp/rust-objc-exception)`

Caused by:
  process didn't exit successfully: `/Users/nobuyuki.tomizawa/tmp/rust-objc-exception/target/debug/build/objc_exception-5b324d21c8cf2fb8/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("0")
  HOST = Some("aarch64-apple-darwin")
  CC_aarch64-apple-darwin = None
  CC_aarch64_apple_darwin = None
  HOST_CC = None
  CC = None
  CFLAGS_aarch64-apple-darwin = None
  CFLAGS_aarch64_apple_darwin = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-Wall" "-Wextra" "-o" "/Users/nobuyuki.tomizawa/tmp/rust-objc-exception/target/debug/build/objc_exception-6c2bc82e40383247/out/extern/exception.o" "-c" "extern/exception.m"
  cargo:warning=extern/exception.m: In function 'RustObjCExceptionThrow':
  cargo:warning=extern/exception.m:5:5: error: '-fobjc-exceptions' is required to enable Objective-C exception syntax
  cargo:warning=    5 |     @throw exception;
  cargo:warning=      |     ^~~~~~
  cargo:warning=extern/exception.m:4:32: warning: parameter 'exception' set but not used [-Wunused-but-set-parameter]
  cargo:warning=    4 | void RustObjCExceptionThrow(id exception) {
  cargo:warning=      |                             ~~~^~~~~~~~~
  exit status: 1

  --- stderr


  error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-Wall" "-Wextra" "-o" "/Users/nobuyuki.tomizawa/tmp/rust-objc-exception/target/debug/build/objc_exception-6c2bc82e40383247/out/extern/exception.o" "-c" "extern/exception.m" with args "cc" did not execute successfully (status code exit status: 1).

The following fix looks woking both GCC and macOS's CC.

diff --git a/build.rs b/build.rs
index ba728b6..8a66997 100644
--- a/build.rs
+++ b/build.rs
@@ -2,6 +2,8 @@ extern crate cc;

 fn main() {
     cc::Build::new()
+       .flag("-fobjc-exceptions")
+       .flag("-Wunused-but-set-parameter")
         .file("extern/exception.m")
         .compile("libexception.a");
 }
``

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant