Giter Site home page Giter Site logo

rust's Issues

Can't compile project with ada-url

Hey. First of all, thanks for this package 🙏 !

I've tried using it in an empty project, and just followed the Usage section in the readme.

On macOS, I get this error when running my project.

❯ cargo run
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling thiserror v1.0.44
   Compiling quote v1.0.32
   Compiling syn v2.0.28
   Compiling thiserror-impl v1.0.44
   Compiling ada-url v1.0.0
   Compiling url-tester v0.1.0 (/Users/sam/Projects/rust/url-tester)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin:/Users/sam/Library/Android/sdk/emulator:/Users/sam/Library/Android/sdk/tools:/Users/sam/Library/Android/sdk/platform-tools:/Users/sam/.rbenv/shims:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/X11/bin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/sam/Library/Android/sdk/emulator:/Users/sam/Library/Android/sdk/tools:/Users/sam/Library/Android/sdk/platform-tools:/Users/sam/.rbenv/shims:/opt/local/bin:/opt/local/sbin:/Users/sam/.cargo/bin" VSLANG="1033" ZERO_AR_DATE="1" "cc" "-arch" "x86_64" "-m64" "/var/folders/x6/x_6hcrfd4wlgtrhl3mk_k8nr0000gn/T/rustcZucdXj/symbols.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.17ka8444finmgkq.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.1wp8jgkl4rv6r0qn.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.2kts0tdd7dmawpag.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.37t1jqa0j5zxveep.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.3iollo6wy7ol8cav.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.3t1k1luwlfsmsyf3.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.4g8r3ez6fiord2ts.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.4ob6dn8s8ywitjgd.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.53t56galqq8nhocv.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.ni89es2ecjh8znp.rcgu.o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17.2u1zfl1ur1dr94pb.rcgu.o" "-L" "/Users/sam/Projects/rust/url-tester/target/debug/deps" "-L" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/sam/Projects/rust/url-tester/target/debug/deps/libada_url-db68e6afe958d9e4.rlib" "/Users/sam/Projects/rust/url-tester/target/debug/deps/libthiserror-24e30db8717d7357.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-27e1b03a0426d4cf.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-341c0fc2da3427c8.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-52cfef9d763ce259.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libmemchr-f09169d1042f3a05.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-7defd84565f529d4.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-74d90d90e229e78a.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-e1717ff4388817ba.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd_detect-4fa4169372ed1da3.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-dcb2e06f8e52a96e.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-d787f607fd46c9e2.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libminiz_oxide-3bf5b5d0104db839.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libadler-2460212a2dea708e.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-b6786e4f5040847e.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-b013e4b8a817dc81.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-64e229fb99f65f8e.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-0a26e9a040c082ad.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-9e4deae0b6825973.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-39ae77fee7b9a032.rlib" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-3c87f4e27c528865.rlib" "-lSystem" "-lc" "-lm" "-L" "/Users/sam/.rustup/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/sam/Projects/rust/url-tester/target/debug/deps/url_tester-ff7ede934e779f17" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: Undefined symbols for architecture x86_64:
            "_ada_free", referenced from:
                _$LT$ada_url..Url$u20$as$u20$core..ops..drop..Drop$GT$::drop::h2ecad21de5d2976b in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_get_hash", referenced from:
                ada_url::Url::hash::h7329f6ab3b327011 in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_get_href", referenced from:
                ada_url::Url::href::hcba3e5e5bc46f4db in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_get_pathname", referenced from:
                ada_url::Url::pathname::h828ddc8379d0084b in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_get_port", referenced from:
                ada_url::Url::port::h051822151e973431 in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_is_valid", referenced from:
                ada_url::Url::parse::h8a351a15f4878b3d in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_parse", referenced from:
                ada_url::Url::parse::h8a351a15f4878b3d in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_parse_with_base", referenced from:
                ada_url::Url::parse::h8a351a15f4878b3d in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
            "_ada_set_port", referenced from:
                ada_url::Url::set_port::h647f863092587e3f in libada_url-db68e6afe958d9e4.rlib(ada_url-db68e6afe958d9e4.ada_url.b80e40fcfe2edb5c-cgu.0.rcgu.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

error: could not compile `url-tester` (bin "url-tester") due to previous error

So I was wondering if this had anything to do with my system. So I started a Rust Docker container, but I get an identical error.

/project # cargo run
   Compiling thiserror-impl v1.0.44
   Compiling thiserror v1.0.44
   Compiling ada-url v1.0.0
   Compiling url-tester v0.1.0 (/project)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/bin:/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/bin/self-contained:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "-m64" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbeginS.o" "/tmp/rustc6BfQ5p/symbols.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.15x8r3pvnt8xt0k8.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.1ech3kjkbkt4skdc.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.1uce5m7acpkpl2o5.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.289eb3au6vfez18l.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.3z31gsycvbeti094.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.42pqn3rbl8l2ndmz.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.4flp19qcjrnygmj6.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.4ommv2zum2zbr58h.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.ctbcpzyhbhxq0pn.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.ivscz4h683bdd3w.rcgu.o" "/project/target/debug/deps/url_tester-386afd2c42fafb55.3a3gtlrj0h1z9xnl.rcgu.o" "-Wl,--as-needed" "-L" "/project/target/debug/deps" "-L" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib" "/project/target/debug/deps/libthiserror-479ab1b39f79ea22.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-493936ddc336b3cf.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-3dd70cbadf3e1002.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libobject-3558ee77f8b1ad74.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libmemchr-10f2552578618c97.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libaddr2line-7b520da5a73d1918.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libgimli-3702969c0e889474.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_demangle-c0cc4c329ee15590.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_detect-874514dffe09e03c.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libhashbrown-e3f573f6d5b58355.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_alloc-85dc525393d56c52.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libminiz_oxide-36ca93bbf21bf97c.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libadler-1041082638612281.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-e11982fd4ee76f53.rlib" "-lunwind" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcfg_if-78634847bd9095da.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-930f912cc77d37c5.rlib" "-lc" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-8cc0612c0889f762.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-918df048a2f8e1f4.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-d1705156e6561f5f.rlib" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-9ad5603f71a0f0cc.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/project/target/debug/deps/url_tester-386afd2c42fafb55" "-Wl,--gc-sections" "-static-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtendS.o" "/usr/local/rustup/toolchains/1.71.1-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `<ada_url::Url as core::ops::drop::Drop>::drop':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:125: undefined reference to `ada_free'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `ada_url::Url::parse':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:149: undefined reference to `ada_parse'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:142: undefined reference to `ada_parse_with_base'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:152: undefined reference to `ada_is_valid'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `ada_url::Url::href':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:192: undefined reference to `ada_get_href'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `ada_url::Url::port':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:216: undefined reference to `ada_get_port'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `ada_url::Url::set_port':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:220: undefined reference to `ada_set_port'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `ada_url::Url::hash':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:224: undefined reference to `ada_get_hash'
          /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: /project/target/debug/deps/libada_url-4d04d94293a4aa35.rlib(ada_url-4d04d94293a4aa35.ada_url.78774d7421f0c0b6-cgu.6.rcgu.o): in function `ada_url::Url::pathname':
          /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ada-url-1.0.0/src/lib.rs:248: undefined reference to `ada_get_pathname'
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `url-tester` (bin "url-tester") due to previous error

Do I have to do anything special to get this crate working? I'm kinda out of ideas on what to do here.

Kind regards
Sam

Feature `libcpp` doesn't compile

Steps to reproduce

cargo test --features=libcpp

Expected behavior

It compiles and runs test successfully.

Actual behavior

warning: In file included from ./deps/ada.cpp:3:
warning: ./deps/ada.h:20:10: fatal error: 'string' file not found
warning: #include <string>
warning:          ^~~~~~~~
warning: 1 error generated.

Test script fails on macOS

Test.sh file fails to run on macOS with the following error message.

➜  ada-rust git:(main) ✗ ./test.sh
STEP: Test
./test.sh: line 14: extra_args[@]: unbound variable

cc @KSXGitHub

Profile-Guided Optimization (PGO) benchmark result

Hi!

I do ongoing PGO research on different applications - all results are available at https://github.com/zamazan4ik/awesome-pgo . I performed some PGO benchmarks on the ada-url library and want to share my results here.

Test environment

  • Fedora 39
  • Linux kernel 6.7.6
  • AMD Ryzen 9 5900x
  • 48 Gib RAM
  • SSD Samsung 980 Pro 2 Tib
  • Compilers - Rustc 1.76 and Clang 17.0.6
  • Ada-url version: Rust bindings on main branch on commit be5c26098f3cec1679dbb453d22542c9a7b10902
  • Disabled Turbo boost for improving consistency across runs

Benchmark

The release benchmark is done with taskset -c 0 cargo bench, PGO training phase - with CXX=clang++ CXXFLAGS="-fprofile-generate=pgo_profiles_clang" cargo pgo bench, PGO-optimized results - with export CXX=clang++ && export CXXFLAGS=ada.profdata && taskset -c 0 cargo pgo optimize bench.

taskset -c 0 is used for better benchmark consistency. PGO profiles for Clang I got with llvm-profdata tool (more details could be found in the Clang documentation).

In all tests, the Clang compiler is used. All PGO-related routines are done with cargo-pgo. All benchmarks are done on the same machine, with the same hardware/software during runs, with the same background "noise" (as much as I can guarantee, of course).

Results

Here are the results:

For anyone wondering, the improvement comes from optimizing with PGO the Rust part or C++ part, I also performed the PGO test only for the C++ part. It's done via passing -fprofile-use flag via CXXFLAGS but running benchmarks with cargo bench (so no PGO-optimization for the Rust part). The results: https://gist.github.com/zamazan4ik/975036b1cd4ede6e4e6eeab2146934e1 . The benchmark confirms that C++ performance is improved with PGO.

At least in the provided by project benchmarks, there are measurable improvements. Not sure if should I create the PGO performance report in the main ada-url repo or not - it's up to the maintainers :)

Please do not treat the issue as a bug - it's just a performance report. If maintainers agree that building the library with PGO can be valuable for the users, maybe mentioning PGO building somewhere in the README will be a good idea to consider.

Is it possible to compile a rust project which uses ada-url to WASM?

First off, thanks for the awesome crate. Also, I apologize for creating an issue for a question.

I'm wondering if it is possible to use ada-url in a project when compiling to WASM? I've experimented with it and haven't had much luck. At the same time, I have no experience with WASM so I'm hoping that I am missing something.

For context, I'm building a JSON Schema crate. At some point in the future, I'd like to compile it to WASM. While I'd really like to use ada-url, I also do not want to pick up a dependency that makes a WASM target impractical.

Thank you for your time. Again, I'm sorry this is somewhat off topic. Please feel free to close if you'd prefer to keep issues to... well, issues.

fails to build on debian sid

Hi,

Building ada-url on debian sid fails.
Running the following commands:

git clone --depth=1 https://github.com/ada-url/rust.git ada-url
cd ada-url
cargo build
Produces the following output:
   Compiling ada-url v2.2.1 (/ada-url)
The following warnings were emitted during compilation:

warning: [email protected]: In file included from ./deps/ada.cpp:3:
warning: [email protected]: ./deps/ada.h:20:10: fatal error: 'string' file not found
warning: [email protected]: #include <string>
warning: [email protected]:          ^~~~~~~~
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `ada-url v2.2.1 (/ada-url)`

Caused by:
  process didn't exit successfully: `/ada-url/target/debug/build/ada-url-ba3156cf87bc7d44/build-script-build` (exit status: 1)
  --- stdout
  OPT_LEVEL = Some("0")
  TARGET = Some("x86_64-unknown-linux-gnu")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CXX_x86_64-unknown-linux-gnu
  CXX_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXX_x86_64_unknown_linux_gnu
  CXX_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXX
  HOST_CXX = None
  cargo:rerun-if-env-changed=CXX
  CXX = Some("clang++")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64-unknown-linux-gnu
  CXXFLAGS_x86_64-unknown-linux-gnu = None
  cargo:rerun-if-env-changed=CXXFLAGS_x86_64_unknown_linux_gnu
  CXXFLAGS_x86_64_unknown_linux_gnu = None
  cargo:rerun-if-env-changed=HOST_CXXFLAGS
  HOST_CXXFLAGS = None
  cargo:rerun-if-env-changed=CXXFLAGS
  CXXFLAGS = None
  running: "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-std=c++17" "-I" "./deps/ada.h" "-I" "./deps/ada_c.h" "-Wall" "-Wextra" "-o" "/ada-url/target/debug/build/ada-url-b4939785ec9bcc43/out/./deps/ada.o" "-c" "./deps/ada.cpp"
  cargo:warning=In file included from ./deps/ada.cpp:3:

  cargo:warning=./deps/ada.h:20:10: fatal error: 'string' file not found

  cargo:warning=#include <string>

  cargo:warning=         ^~~~~~~~

  cargo:warning=1 error generated.

  exit status: 1

  --- stderr


  error occurred: Command "clang++" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-std=c++17" "-I" "./deps/ada.h" "-I" "./deps/ada_c.h" "-Wall" "-Wextra" "-o" "/ada-url/target/debug/build/ada-url-b4939785ec9bcc43/out/./deps/ada.o" "-c" "./deps/ada.cpp"with args "clang++" did not execute successfully (status code exit status: 1).

It seems that clang cannot find the c++ stdlib... 🤔
Moreover, the build script unconditionally sets the compiler to clang++, which makes trying another compiler (or another clang version) impossible.

If I comment out the aforementioned line and build with CXX=g++ cargo build, the library builds correctly and tests pass:

$ CXX=g++ cargo build
   Compiling ada-url v2.2.1 (/ada-url)
warning: [email protected]: cc1plus: warning: ./deps/ada.h: not a directory
warning: [email protected]: cc1plus: warning: ./deps/ada_c.h: not a directory
    Finished dev [unoptimized + debuginfo] target(s) in 3.57s

Also note the warnings caused by the build script's passing files to cc::Build::include() instead of directories.

IMO, the build script should let the cc crate detect the correct compiler on UNIX platforms.

Removing a single FFI call improves performance by 12%

I thought that Rust had a zero-overhead FFI... Anybody has any idea how is this possible?

Benchmark

     Running bench/parse.rs (target/release/deps/parse-9cfaaebee9c9be83)
url_parse/ada_parse     time:   [2.3261 µs 2.3322 µs 2.3385 µs]
                        change: [-12.937% -11.942% -11.185%] (p = 0.00 < 0.05)
                        Performance has improved.

Change

--- a/src/lib.rs
+++ b/src/lib.rs
@@ -171,13 +171,13 @@ impl Url {
             None => unsafe { ffi::ada_parse(input.as_ptr().cast(), input.len()) },
         };

-        if unsafe { ffi::ada_is_valid(url_aggregator) } {
+        // if unsafe { ffi::ada_is_valid(url_aggregator) } {
             Ok(Url {
                 url: url_aggregator,
             })
-        } else {
-            Err(Error::ParseUrl(input.to_owned()))
-        }
+        // } else {
+        //     Err(Error::ParseUrl(input.to_owned()))
+        // }
     }

     /// Returns whether or not the URL can be parsed or not.

FYI: ada_is_valid just calls url_aggregator.has_value().

No API to retrieve the schema type

While using the Rust crate for ada-url I have noticed that there's only url.host_type() but there's no getter for the schema type. It'd be great if we could expose the schema type as well so we have the same API surface as the C++ lib.

For example:

let url = Url::parse(href, None).expect("bad url");
let schema_type = url.schema_type();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.