clash-rs icon indicating copy to clipboard operation
clash-rs copied to clipboard

Could change boringssl to openssl?

Open xmh0511 opened this issue 1 year ago • 14 comments

Currently, the vendor library boringssl needs too many pre-requirements, and I cannot build this project on my macOs, which reports the error:

clang: error: unsupported argument '-g' to option 'Wa,'

Could change boringssl to openssl to simplify the process of installing dependencies?

xmh0511 avatar Dec 05 '23 09:12 xmh0511

What steps did you do to build? It builds fine with cargo build. Also maybe check out the scripts that's used in the release pipeline.

ibigbug avatar Dec 05 '23 15:12 ibigbug

What steps did you do to build? It builds fine with cargo build. Also maybe check out the scripts that's used in the release pipeline.

I downloaded the specified boringssl library and put it into /deps/boringssl/src, then run command cargo build in the root path of the project, then I got the error:

failed to run custom build command for `boring-sys v4.1.0 (https://github.com/Watfaq/boring.git?rev=58d5e7c66b537989bde45d20ce54aff11de1bcea#58d5e7c6)
Caused by:
  process didn't exit successfully:
   clash-rs/target/debug/build/boring-sys-8b2519b964cebd35/build-script-main` (exit status: 101)

/clash-rs/target/debug/build/boring-sys-13745e563ce78ad0/out/build
running: cd /clash-rs/target/debug/build/boring-sys-13745e563ce78ad0/out/build" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "cmake" "--build" "." "--target" "ssl" "--config" "Debug"
  [  0%] Built target boringssl_prefix_symbols
  [  0%] Building ASM object crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesv8-armv8-apple.S.o

  --- stderr
  clang: error: unsupported argument '-g' to option 'Wa,'
  make[3]: *** [crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesv8-armv8-apple.S.o] Error 1
  make[2]: *** [crypto/fipsmodule/CMakeFiles/fipsmodule.dir/all] Error 2
  make[1]: *** [ssl/CMakeFiles/ssl.dir/rule] Error 2
  make: *** [ssl] Error 2
thread 'main' panicked at /.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 2

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

xmh0511 avatar Dec 06 '23 02:12 xmh0511

Doing git submodule update should work.

Boringssl changes their APIs every now and then and it's quite likely to break if the version mismatch.

ibigbug avatar Dec 06 '23 02:12 ibigbug

Doing git submodule update should work.

Boringssl changes their APIs every now and then and it's quite likely to break if the version mismatch.

I did download the version specified by this project. BTW, when I ran the command git submodule update, I got another error:

fatal: Needed a single revision
Unable to find current revision in submodule path 'deps/boringssl/src'

xmh0511 avatar Dec 06 '23 02:12 xmh0511

Yeah I see, there seems to be something wrong with the submodule.

I should fix that or maybe just vendor the source code.

You can try git submodule foreach git pull origin master and then do submodule update.

ibigbug avatar Dec 06 '23 04:12 ibigbug

Yeah I see, there seems to be something wrong with the submodule.

I should fix that or maybe just vendor the source code.

You can try git submodule foreach git pull origin master and then do submodule update.

Separately build boringssl is OK, however, under the cargo build, it always gives the above error. My platform is macOS.

xmh0511 avatar Dec 06 '23 05:12 xmh0511

The issue about the submodule may be resolved with the following steps:

  1. git clone this project
  2. Before any modification to this project, run the command git submodule update --init

However, On macOS, I still get the error: clang: error: unsupported argument '-g' to option 'Wa,', which stops at [ 20%] Building ASM object crypto/fipsmodule/CMakeFiles/fipsmodule.dir/aesv8-armv8-apple.S.o. On Linux, the error is CMake Error at cmake/go.cmake:12 (message): Could not find Go, which may need the installation of Golang.

My suggestion is that clash-rs as a project of Rust, we should have as less dependencies on other languages as possible and make the project easy to build such that more people can easily participate the contributing to this project.

xmh0511 avatar Dec 06 '23 06:12 xmh0511

Hmmm, On macOS, the solution to the above error is to change one line code in deps/boringssl/src/CMakeList.txt

if(NOT CMAKE_ASM_COMPILER_ID MATCHES "Clang")
      set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Wa,-g")
endif()

Remove -Wa,-g, which works for me.

xmh0511 avatar Dec 06 '23 06:12 xmh0511

You can have a try: cd deps/boringssl/src && git pull. It might be a workaround for it,.

greenhat616 avatar Dec 06 '23 11:12 greenhat616

yes, we should look at fixing the submodule stuff, it's kind of annoying

ibigbug avatar Dec 06 '23 11:12 ibigbug

You can have a try: cd deps/boringssl/src && git pull. It might be a workaround for it,.

It cannot work. the issue is some wrong config in CMakeList.txt in that submodule on macOS platform.

xmh0511 avatar Dec 06 '23 12:12 xmh0511

could be a cmake version mismatch https://github.com/OpenMathLib/OpenBLAS/issues/3931#issuecomment-1452187213

ibigbug avatar Dec 06 '23 12:12 ibigbug

https://github.com/cloudflare/quiche/issues/644#issuecomment-703188583

xmh0511 avatar Jan 01 '24 13:01 xmh0511

@xmh0511 do you mind drafting a guide for what you have experienced for setting up the build ?

ibigbug avatar Jan 01 '24 13:01 ibigbug