Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

target-cpu shouldn't default to native when cross-compiling #374

Open
1 task done
kornelski opened this issue Feb 11, 2025 · 8 comments
Open
1 task done

target-cpu shouldn't default to native when cross-compiling #374

kornelski opened this issue Feb 11, 2025 · 8 comments

Comments

@kornelski
Copy link
Contributor

kornelski commented Feb 11, 2025

  • The --mca option doesn't work on ARM due to assuming Intel asm syntax.

I've tried working around this by adding cross compilation --target=x86_64-apple-darwin, but this results in no output at all, except:

'apple-m3' is not a recognized processor for this target (ignoring processor)

I needed to add --target-cpu=skylake --mca-arg=-skip-unsupported-instructions=parse-failure to get it working.


When crosscompiling with llvm-mca you need to specify which CPU to use for timing information - it defaults to your current platform and error messages can be confusing.

@pacak
Copy link
Owner

pacak commented Feb 11, 2025

Is it working if you pass --att?

@pacak
Copy link
Owner

pacak commented Feb 13, 2025

Can you check if master works for you on ARM without having to pass anything special?

@kornelski
Copy link
Contributor Author

kornelski commented Feb 16, 2025

When not cross-compiling, --mca on ARM works without any extra args. Works with --att too.

@pacak
Copy link
Owner

pacak commented Feb 16, 2025 via email

@pacak
Copy link
Owner

pacak commented Feb 16, 2025 via email

@kornelski
Copy link
Contributor Author

However, when cross-compiling from ARM to x86-64, it still needs --target-cpu=<something made by intel> and it needs --att

cargo r -- asm --mca --target=x86_64-apple-darwin -vv --lib 'asm::llvm::Llvm as cargo_show_asm::Dumpable>::dump_range'
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/cargo-asm asm --mca --target=x86_64-apple-darwin -vv --lib 'asm::llvm::Llvm as cargo_show_asm::Dumpable>::dump_range'`
Found sysroot: /Users/kornel/.rustup/toolchains/nightly-aarch64-apple-darwin
Running: "/Users/kornel/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo" "rustc" "--message-format=json-render-diagnostics" "--color" "always" "-v" "-v" "--manifest-path" "/Users/kornel/www/cargo-show-asm/Cargo.toml" "--config" "profile.release.strip=false" "--package" "cargo-show-asm" "--lib" "--target" "x86_64-apple-darwin" "--release" "--" "--emit" "asm" "-C" "llvm-args=-x86-asm-syntax=intel" "-Cdebuginfo=2" "-Ccodegen-units=1"
       Fresh cargo-show-asm v0.2.47 (/Users/kornel/www/cargo-show-asm)
    Finished `release` profile [optimized] target(s) in 0.01s

Artifact files: ["/Users/kornel/www/cargo-show-asm/target/x86_64-apple-darwin/release/libcargo_show_asm.rlib", "/Users/kornel/www/cargo-show-asm/target/x86_64-apple-darwin/release/deps/libcargo_show_asm-defff629b9f991b5.rmeta"]
Working with file: /Users/kornel/www/cargo-show-asm/target/x86_64-apple-darwin/release/deps/cargo_show_asm-defff629b9f991b5.s
running "llvm-mca" "--mtriple" "x86_64-apple-darwin"
'apple-m3' is not a recognized processor for this target (ignoring processor)
'apple-m3' is not a recognized processor for this target (ignoring processor)

@kornelski
Copy link
Contributor Author

kornelski commented Feb 16, 2025

works: asm --mca --att --target=x86_64-apple-darwin -vv --lib 'Llvm as cargo_show_asm::Dumpable>::dump_range' --target-cpu=skylake

but with --intel (or just no --att)

running "llvm-mca" "--mtriple" "x86_64-apple-darwin" "--mcpu" "skylake"
<stdin>:4:1: error: unknown use of instruction mnemonic without a size suffix
mov rbp, rsp
^
<stdin>:11:1: error: unknown use of instruction mnemonic without a size suffix
sub rsp, 120
^
<stdin>:13:1: error: unknown use of instruction mnemonic without a size suffix
test rcx, rcx
^

@pacak
Copy link
Owner

pacak commented Feb 16, 2025

However, when cross-compiling from ARM to x86-64, it still needs --target-cpu=<something made by intel>

Yeah, same problem when cross compiling from x86 to ARM. While I can pick some concrete processor for cross-compilation - timings are not going to match. Maybe a better approach is to detect cross-compilation case and print some suggestions... Going to experiment a bit more before releasing then.

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

No branches or pull requests

2 participants