What's the best `target-cpu` option for s390x cross-compiling?

What's a suitable -Ctarget-cpu=... for s390x cross-compiling target. Like below

[target.'cfg(target_arch="s390x")']
rustflags = ["-Ctarget-cpu=???", "-Ztune-cpu=???"]
[target.'cfg(all(target_arch="s390x",target_os="linux"))']
linker = "s390x-linux-gnu-gcc"

No idea, but you can list the available cpus with rustc --print target-cpus. This should help you narrow it down.

I tried, but can't find any similar name match s390 IBM power or something else, not sure this is the full list of supported cpus.

For example if cross-compiling to riscv64gc target, you should pass generic-rv64 to target-cpu, but there is NO riscv* or rv* items in rustc --print target-cpus list.

I found the right way to find available target-cpu list for specific target rustc --target=${TRIPLE} --print target-cpus

--print target-cpus by default lists the host cpu models. try use the --target xxx flag for cross compiling targets, e.g.

$ rustc --target riscv64gc-unknown-linux-gnu --print target-cpus
# or
$ rustc --target s390x-unknown-linux-gnu --print target-cpus
1 Like

Note that if all you need is a suitable target-cpu, you should just be able to leave it out completely. The compiler has a default built-in; the reason to choose a non-default option is if you know that you're running on a specific generation of CPU, in which case @nerditation's suggestion of rustc --target s390x-unknown-linux-gnu --print target-cpus will help you find out how to spell the appropriate CPU generation in terms rustc likes.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.