My target cpu is Intel core i7 Which one should I choose from the list below?

hi

My target system is

linux: ubuntu 64bit
cpu: intel core i7

and that support sse3, avx2,
but i dont know which choose from rustc --print target-list
???

aarch64-unknown-linux-gnu
aarch64-unknown-linux-gnu_ilp32
aarch64-unknown-linux-musl

aarch64_be-unknown-linux-gnu
aarch64_be-unknown-linux-gnu_ilp32

i586-unknown-linux-gnu
i586-unknown-linux-musl

i686-unknown-linux-gnu
i686-unknown-linux-musl

mips-unknown-linux-gnu
mips-unknown-linux-musl
mips-unknown-linux-uclibc
mips64-unknown-linux-gnuabi64
mips64-unknown-linux-muslabi64
mips64el-unknown-linux-gnuabi64
mips64el-unknown-linux-muslabi64

mipsel-unknown-linux-gnu
mipsel-unknown-linux-musl

mipsisa32r6-unknown-linux-gnu
mipsisa32r6el-unknown-linux-gnu
mipsisa64r6-unknown-linux-gnuabi64
mipsisa64r6el-unknown-linux-gnuabi64
powerpc-unknown-freebsd
powerpc-unknown-linux-gnu
powerpc-unknown-linux-gnuspe
powerpc-unknown-linux-musl
powerpc64le-unknown-linux-gnu

s390x-unknown-linux-gnu
s390x-unknown-linux-musl
sparc-unknown-linux-gnu
sparc64-unknown-linux-gnu

x86_64-unknown-linux-gnu
x86_64-unknown-linux-gnux32
x86_64-unknown-linux-musl

Hi,
I would pick: x86_64-unknown-linux-gnu

1 Like

The base x86_64 targets aren't going to enable things like sse3 and avx2 by default, but you can also set RUSTFLAGS=-Ctarget-cpu=native if you're only ever going to run your builds locally.

thanks for your attention, yes that code for locally !!
but i need run on another machine and when write bellow code, it printing
all features with labeled, which features are enabled and which are supported
when use x86_64, said (sse3 and avx2) both are enabled by default.

rustc --target=x86_64-unknown-linux-gnu --print target-features

also in this page said both is enable by default

https://doc.rust-lang.org/reference/attributes/codegen.html#the-target_feature-attribute

Using --print target-features shows every feature the compiler knows about for this target, not just those that are enabled. The page you linked is also just available features. Try --print cfg to see the active list, and see how that changes with -Ctarget-cpu.

I saw code of rust compiler in github, itself set basic features for
x86_64 (both are enabled by default)


pub fn target() -> Target {
    let mut base = super::linux_kernel_base::opts();
    base.cpu = "x86-64".to_string();
    base.max_atomic_width = Some(64);
    base.features =
        "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float"
            .to_string();
    base.code_model = Some(CodeModel::Kernel);
    base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());

That's the target for running code in the Linux kernel, not as an application. All of those - features are explicitly disabled, while + enables a feature. The kernel uses +soft-float because it doesn't always save/restore floating point state when it interrupts a process.

1 Like

Actually after deep in the Rust, now
I know what JVM does
And I did not appreciate it (Dynamic Compilation) :grinning_face_with_smiling_eyes:

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.