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

Disable depending on ring for x86, armv7 targets #347

Closed
zonyitoo opened this issue Dec 14, 2020 · 2 comments
Closed

Disable depending on ring for x86, armv7 targets #347

zonyitoo opened this issue Dec 14, 2020 · 2 comments

Comments

@zonyitoo
Copy link
Collaborator

shadowsocks/shadowsocks-android#2622
shadowsocks/crypto2#6

  1. Set RUSTFLAGS separately for x86

[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))']
rustflags = [
# "--print", "native-static-libs",
# "-C", "target-cpu=native",
"-C", "target-feature=+aes,+pclmul,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+avx,+avx2,+fma,adx",
]

  1. Disable ring for x86 and armv7 compile target

[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies]
shadowsocks-crypto = { version = "0.1", features = ["ring"] }
[target.'cfg(any(target_arch = "arm", target_arch = "aarch64"))'.dependencies]
shadowsocks-crypto = { version = "0.1", features = ["ring"] }

@madeye Please verify if these modification works for your x86 Android device.

@madeye
Copy link
Contributor

madeye commented Dec 14, 2020

Yes, with the following change, shadowsocks-rust works now on x86 android simulator.

--- a/.cargo/config.toml
+++ b/.cargo/config.toml

@@ -3,7 +3,14 @@ rustflags = [
     # "--print", "native-static-libs",
 ]

-[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))']
+[target.'cfg(any(target_arch = "x86"))']
+rustflags = [
+    # "--print", "native-static-libs",
+    # "-C", "target-cpu=native",
+    "-C", "target-feature=+aes,+pclmul,+sse,+sse2,+sse3,+ssse3",
+]
+
+[target.'cfg(any(target_arch = "x86_64"))']
 rustflags = [
     # "--print", "native-static-libs",
     # "-C", "target-cpu=native",

--- a/shadowsocks/Cargo.toml
+++ b/shadowsocks/Cargo.toml

@@ -87,10 +87,16 @@ tower = { git = "https://github.com/tower-rs/tower.git", optional = true }
 ipnet = "2.3"
 iprange = "0.6"

-[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies]
+[target.'cfg(any(target_arch = "arm"))'.dependencies]
+shadowsocks-crypto = { version = "0.1" }
+
+[target.'cfg(any(target_arch = "x86"))'.dependencies]
+shadowsocks-crypto = { version = "0.1" }
+
+[target.'cfg(any(target_arch = "x86_64"))'.dependencies]
 shadowsocks-crypto = { version = "0.1", features = ["ring"] }

-[target.'cfg(any(target_arch = "arm", target_arch = "aarch64"))'.dependencies]
+[target.'cfg(any(target_arch = "aarch64"))'.dependencies]
 shadowsocks-crypto = { version = "0.1", features = ["ring"] }

 [target.'cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm", target_arch = "aarch64")))'.dependencies]

@zonyitoo
Copy link
Collaborator Author

Great. These changes will be included in v1.9.0 release.

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

No branches or pull requests

2 participants