Skip to content

[Flang] Driver hardcodes lib/libflang_rt.a path that is incorrect on lib64 systems, and does not permit multilib #127538

Open
@mgorny

Description

@mgorny

I'm almost ready to package Flang on Gentoo. The remaining problem is that the driver hardcodes the lib directory for libflang_rt.a:

void tools::addFortranRuntimeLibraryPath(const ToolChain &TC,
const llvm::opt::ArgList &Args,
ArgStringList &CmdArgs) {
// Default to the <driver-path>/../lib directory. This works fine on the
// platforms that we have tested so far. We will probably have to re-fine
// this in the future. In particular, on some platforms, we may need to use
// lib64 instead of lib.
SmallString<256> DefaultLibPath =
llvm::sys::path::parent_path(TC.getDriver().Dir);
llvm::sys::path::append(DefaultLibPath, "lib");

This is problematic for two reasons:

  1. Gentoo is using lib64 for 64-bit libraries on platforms such on amd64, and lib for 32-bit libraries, and installing a 64-bit library into lib is generally an error.
  2. The forced use of a single library directory makes cross-compilation / multilib builds impossible. I haven't tested how well Flang works with that yet, but at least a dumb flang --target=i686-pc-linux-gnu hello.f90 seems to work, modulo trying to link a 64-bit runtime.

I've tried fiddling a fair bit, and unfortunately I don't see any good way of getting the correct lib* directory in that code. Perhaps the correct approach would be to include the architecture in the filename the way compiler-rt does — and perhaps move it to clang's resource directory while at it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions