{"action":"created","issue":{"url":"https://api.github.com/repos/zonyitoo/context-rs/issues/31","repository_url":"https://api.github.com/repos/zonyitoo/context-rs","labels_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/31/comments","events_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/31/events","html_url":"https://github.com/zonyitoo/context-rs/issues/31","id":176593197,"number":31,"title":"Does not cross-compile for `x86_64-unknown-linux-musl` on Mac OS X El Capitan","user":{"login":"raphaelcohn","id":1307097,"avatar_url":"https://avatars.githubusercontent.com/u/1307097?v=3","gravatar_id":"","url":"https://api.github.com/users/raphaelcohn","html_url":"https://github.com/raphaelcohn","followers_url":"https://api.github.com/users/raphaelcohn/followers","following_url":"https://api.github.com/users/raphaelcohn/following{/other_user}","gists_url":"https://api.github.com/users/raphaelcohn/gists{/gist_id}","starred_url":"https://api.github.com/users/raphaelcohn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raphaelcohn/subscriptions","organizations_url":"https://api.github.com/users/raphaelcohn/orgs","repos_url":"https://api.github.com/users/raphaelcohn/repos","events_url":"https://api.github.com/users/raphaelcohn/events{/privacy}","received_events_url":"https://api.github.com/users/raphaelcohn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-13T09:32:15Z","updated_at":"2016-09-13T10:07:13Z","closed_at":null,"body":"Thank you for your work on `context-rs` - it's a great library, and a wonderful example of how to make something difficult to implement and reason about simple to use!\r\n\r\nIt works absolutely fine on Mac OS X El Capitan, but when trying to cross-compile using `cargo build --target x86_64-unknown-linux-musl` (from a crate using it as an upstream dependency) on the same, there's a build script error - primarily because the build script looks for `musl-gcc`.\r\n\r\nAs an aside, looking for `musl-gcc` won't work even on some Linux platforms where `musl` is the default lib. That's because when the system library's musl, `musl-gcc` doesn't exist. That also is true for any system using `musl-cross-make`, the musl author's own build system for making musl-based system compilers. I don't know if this a `context` issue or something deeper in cargo / rustc / rustup. If this is misdirected, I'm happy to file against the correct component and close this issue.\r\n\r\nAlternatively, would it be possible to embed the assembler you're compiling with Rust's `asm` macro? I'm not sure how mature this macro is, or how to use it, so I might be suggesting something inappropriate.\r\n\r\nActual Error:-\r\n```bash\r\n   Compiling context v1.0.0\r\n     Running `rustc /Users/raph/.cargo/registry/src/github.com-1ecc6299db9ec823/context-1.0.0/build.rs --crate-name build_script_build --crate-type bin -g -C metadata=27e11b7b5bc898d2 --out-dir /Volumes/Source/GitHub/lemonrock/netio/.cargo/target/debug/build/context-27e11b7b5bc898d2 --emit=dep-info,link -L dependency=/Volumes/Source/GitHub/lemonrock/netio/.cargo/target/debug/deps --extern gcc=/Volumes/Source/GitHub/lemonrock/netio/.cargo/target/debug/deps/libgcc-d21f77bcf393feb8.rlib --cap-lints allow`\r\n     Running `/Volumes/Source/GitHub/lemonrock/netio/.cargo/target/debug/build/context-27e11b7b5bc898d2/build-script-build`\r\nerror: failed to run custom build command for `context v1.0.0`\r\nprocess didn't exit successfully: `/Volumes/Source/GitHub/lemonrock/netio/.cargo/target/debug/build/context-27e11b7b5bc898d2/build-script-build` (exit code: 101)\r\n--- stdout\r\nTARGET = Some(\"x86_64-unknown-linux-musl\")\r\nOPT_LEVEL = Some(\"0\")\r\nPROFILE = Some(\"debug\")\r\nTARGET = Some(\"x86_64-unknown-linux-musl\")\r\ndebug=true opt-level=0\r\nHOST = Some(\"x86_64-apple-darwin\")\r\nTARGET = Some(\"x86_64-unknown-linux-musl\")\r\nTARGET = Some(\"x86_64-unknown-linux-musl\")\r\nHOST = Some(\"x86_64-apple-darwin\")\r\nCC_x86_64-unknown-linux-musl = None\r\nCC_x86_64_unknown_linux_musl = None\r\nTARGET_CC = None\r\nCC = None\r\nHOST = Some(\"x86_64-apple-darwin\")\r\nTARGET = Some(\"x86_64-unknown-linux-musl\")\r\nHOST = Some(\"x86_64-apple-darwin\")\r\nCFLAGS_x86_64-unknown-linux-musl = None\r\nCFLAGS_x86_64_unknown_linux_musl = None\r\nTARGET_CFLAGS = None\r\nCFLAGS = None\r\nrunning: \"musl-gcc\" \"-O0\" \"-ffunction-sections\" \"-fdata-sections\" \"-g\" \"-m64\" \"-fPIC\" \"-static\" \"-DBOOST_CONTEXT_EXPORT\" \"-o\" \"/Volumes/Source/GitHub/lemonrock/netio/.cargo/target/x86_64-unknown-linux-musl/debug/build/context-27e11b7b5bc898d2/out/src/asm/jump_x86_64_sysv_elf_gas.o\" \"-c\" \"src/asm/jump_x86_64_sysv_elf_gas.S\"\r\n\r\n\r\nfailed to execute command: No such file or directory (os error 2)\r\nIs `musl-gcc` not installed?\r\n\r\n\r\n\r\n--- stderr\r\nthread 'main' panicked at 'explicit panic', /Users/raph/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.35/src/lib.rs:897\r\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/zonyitoo/context-rs/issues/comments/246635553","html_url":"https://github.com/zonyitoo/context-rs/issues/31#issuecomment-246635553","issue_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/31","id":246635553,"user":{"login":"lhecker","id":2256941,"avatar_url":"https://avatars.githubusercontent.com/u/2256941?v=3","gravatar_id":"","url":"https://api.github.com/users/lhecker","html_url":"https://github.com/lhecker","followers_url":"https://api.github.com/users/lhecker/followers","following_url":"https://api.github.com/users/lhecker/following{/other_user}","gists_url":"https://api.github.com/users/lhecker/gists{/gist_id}","starred_url":"https://api.github.com/users/lhecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lhecker/subscriptions","organizations_url":"https://api.github.com/users/lhecker/orgs","repos_url":"https://api.github.com/users/lhecker/repos","events_url":"https://api.github.com/users/lhecker/events{/privacy}","received_events_url":"https://api.github.com/users/lhecker/received_events","type":"User","site_admin":false},"created_at":"2016-09-13T10:07:13Z","updated_at":"2016-09-13T10:07:13Z","body":"Like most Rust projects we use the `gcc` crate to compile non-Rust code. The name \"gcc\" is a bit misleading here though, since it supports almost all platforms and compilers Rust itself works on too.\r\n[This](https://github.com/zonyitoo/context-rs/blob/master/build.rs) is our build script, which uses the `TARGET` env var to calculate the set of files from [here](https://github.com/zonyitoo/context-rs/tree/master/src/asm) to be compiled with the `gcc` crate. In your case it basically only passed the paths of the `(jump|make|ontop)_x86_64_sysv_elf_gas.S` files to the `gcc` crate which then does the rest.\r\nSo in the end I think `gcc` is at fault here and I believe you should open an issue there. Their logic to split the `TARGET` env var into a compiler name is probably flawed somewhere. I'm pretty sure other projects using the `gcc` crate should fail too for you, right?\r\n\r\nBut since resolving that can take a while you should try to set the `CC` and/or `TARGET_CC` env vars. Using those you should be able to manually specify the correct compilers and successfully build this project.\r\n\r\nRegarding inline-asm: If you do context switching you have to make very specific assumptions about how your CPU works. For instance look at [this](https://github.com/zonyitoo/context-rs/blob/master/src/asm/jump_x86_64_sysv_elf_gas.S). If you know x86_64 assembler you will notice that it's missing the standard function prologue and epilogue. This is not just done because it would be a performance hit (since we have to save `%rbx` anyways for instance), but also because it would mess with the way we want to store the CPU state in memory (more or less depending on the platform).\r\nWhat you'd need to do to embed this using inline-asm is to use \"naked functions\" (`#[naked]`), which is an unstable and thus still a nightly-only feature right now. Since we still want to support stable Rust releases we are still using `gcc` and whenever it lands in stable Rust we will try to make this work without this extra compilation step. But you're of course welcome to try this out right now by pasting those 3 assembly files above into 3 naked Rust functions and post your findings at #16. 🙂"}}
{"actor":{"display_login":"lhecker"}}