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

cli/build.rs requires glibc on Linux #17739

Closed
mdekstrand opened this issue Feb 11, 2023 · 0 comments · Fixed by #19913
Closed

cli/build.rs requires glibc on Linux #17739

mdekstrand opened this issue Feb 11, 2023 · 0 comments · Fixed by #19913

Comments

@mdekstrand
Copy link

mdekstrand commented Feb 11, 2023

Currently build.rs hard-depends on being able to load glibc in order to set linker flags (Line 430):

 #[cfg(target_os = "linux")]
{
  let ver = glibc_version::get_version().unwrap();

  // If a custom compiler is set, the glibc version is not reliable.
  // Here, we assume that if a custom compiler is used, that it will be modern enough to support a dynamic symbol list.
  if env::var("CC").is_err() && ver.major <= 2 && ver.minor < 35 {
    println!("cargo:warning=Compiling with all symbols exported, this will result in a larger binary. Please use glibc 2.35 or later for an optimised build.");
    println!("cargo:rustc-link-arg-bin=deno=-rdynamic");
  } else {
    println!(
      "cargo:rustc-link-arg-bin=deno=-Wl,--export-dynamic-symbol-list={}",
      symbols_path.display()
    );
  }
}

Correcting this is the only source code change I needed to successfully build Deno on Alpine/musl x86_64 and will help address #3711. I would submit a PR directly but am not sure what the best fix here is; the failure is that unwrap() fails, because glibc can't be loaded; in my build I removed all the conditionals and the glibc call here so that it just uses the dynamic symbol list without checking.

Maybe if glibc is missing assume it's good enough? Or should MUSL-building code set CC? That will still require a source edit, because currently glibc is checked before CC. This whole block could also be made dependent on the target also being GNU.

mmastrac pushed a commit that referenced this issue Jul 23, 2023
mmastrac pushed a commit that referenced this issue Jul 26, 2023
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 a pull request may close this issue.

1 participant