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

Ensure beginning and end of the error output is readable #2284

Merged
merged 3 commits into from
Sep 8, 2024

Conversation

kornelski
Copy link
Contributor

When the build fails, the Cargo output is messy, and there's unhelpful noise added at both ends of openssl's message. The beginning of output gets a vague error and long meaningless stdout dump, and the end gets a backtrace of an unimportant code location.

This improves the output in two ways:

  1. Emits cargo:warning= with the first paragraph of the error, so the cause of the failure is printed and highlighted by Cargo first,
  2. Changes a panic to direct stderr print to avoid Rust adding unnecessary panic-related help.

@kornelski kornelski force-pushed the cargo-warnings branch 2 times, most recently from a8f26b8 to b4df3c5 Compare August 28, 2024 14:02
@alex
Copy link
Collaborator

alex commented Aug 29, 2024

Do you have an example of a before-and-after of what this looks like?

@kornelski
Copy link
Contributor Author

kornelski commented Sep 8, 2024

+The following warnings were emitted during compilation:
+
+warning: openssl-sys@0.9.103: Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the compilation process. See stderr section below for further information.
+
 error: failed to run custom build command for `openssl-sys v0.9.103 (~/rust-openssl/openssl-sys)`
 note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
 
 Caused by:
   process didn't exit successfully: `~/rust-openssl/target/debug/build/openssl-sys-fc33f8dce2cb8a74/build-script-main` (exit status: 101)
  --- stdout
   cargo:rustc-check-cfg=cfg(osslconf, values("OPENSSL_NO_OCB", "OPENSSL_NO_SM4", "OPENSSL_NO_SEED", "OPENSSL_NO_CHACHA", "OPENSSL_NO_CAST", "OPENSSL_NO_IDEA", "OPENSSL_NO_CAMELLIA", "OPENSSL_NO_RC4", "OPENSSL_NO_BF", "OPENSSL_NO_PSK", "OPENSSL_NO_DEPRECATED_3_0", "OPENSSL_NO_SCRYPT", "OPENSSL_NO_SM3", "OPENSSL_NO_RMD160", "OPENSSL_NO_EC2M", "OPENSSL_NO_OCSP", "OPENSSL_NO_CMS", "OPENSSL_NO_COMP", "OPENSSL_NO_SOCK", "OPENSSL_NO_STDIO", "OPENSSL_NO_EC", "OPENSSL_NO_SSL3_METHOD", "OPENSSL_NO_KRB5", "OPENSSL_NO_TLSEXT", "OPENSSL_NO_SRP", "OPENSSL_NO_RFC3779", "OPENSSL_NO_SHA", "OPENSSL_NO_NEXTPROTONEG", "OPENSSL_NO_ENGINE", "OPENSSL_NO_BUF_FREELISTS"))
   cargo:rustc-check-cfg=cfg(openssl)
@@ -59,12 +63,22 @@
   AARCH64_APPLE_DARWIN_OPENSSL_DIR unset
   cargo:rerun-if-env-changed=OPENSSL_DIR
   OPENSSL_DIR unset
-  run pkg_config fail: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"opensslbork\"", output: Output { status: ExitStatus(unix_wait_status(256)), stdout: "", stderr: "Package opensslbork was not found in the pkg-config search path.\nPerhaps you should add the directory containing `opensslbork.pc'\nto the PKG_CONFIG_PATH environment variable\nNo package 'opensslbork' found\n" } }
 
+
+  Could not find openssl via pkg-config:
+  `"pkg-config" "--libs" "--cflags" "opensslbork"` did not exit successfully: exit status: 1
   --- stderr
-  thread 'main' panicked at openssl-sys/build/find_normal.rs:190:5:
+  Package opensslbork was not found in the pkg-config search path.
+  Perhaps you should add the directory containing `opensslbork.pc'
+  to the PKG_CONFIG_PATH environment variable
+  No package 'opensslbork' found
 
 
+  cargo:warning=Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the compilation process. See stderr section below for further information.
+
+  --- stderr
+
+
   Could not find directory of OpenSSL installation, and this `-sys` crate cannot
   proceed without this knowledge. If OpenSSL is installed and this crate had
   trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
@@ -81,19 +95,3 @@
   $TARGET = aarch64-apple-darwin
   openssl-sys = 0.9.103
 
-
-  stack backtrace:
-     0: rust_begin_unwind
-               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
-     1: core::panicking::panic_fmt
-               at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
-     2: core::panicking::panic_display
-     3: build_script_main::find_normal::find_openssl_dir::panic_cold_display
-     4: build_script_main::find_normal::find_openssl_dir
-     5: build_script_main::find_normal::get_openssl::{{closure}}
-     6: core::option::Option<T>::unwrap_or_else
-     7: build_script_main::find_normal::get_openssl
-     8: build_script_main::find_openssl
-     9: build_script_main::main
-    10: core::ops::function::FnOnce::call_once
-  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@alex alex merged commit 22a66be into sfackler:master Sep 8, 2024
61 checks passed
@kornelski kornelski deleted the cargo-warnings branch September 8, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants