Skip to content

[flang][Driver] Enable FLANG_DEFAULT_LINKER #149786

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

Merged
merged 3 commits into from
Aug 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ if (NOT ENABLE_LINKER_BUILD_ID)
set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
endif()

set(FLANG_DEFAULT_LINKER "" CACHE STRING
set(FLANG_DEFAULT_LINKER ${CLANG_DEFAULT_LINKER} CACHE STRING
"Default linker to use (linker name or absolute path, empty for platform default)")

set(FLANG_DEFAULT_RTLIB "" CACHE STRING
Expand Down
16 changes: 9 additions & 7 deletions flang/include/flang/Config/config.h.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#===-- include/flang/Config/config.h.cmake ---------------------------------===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#
//===-- include/flang/Config/config.h.cmake -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

/* This generated file is for internal use. Do not include it from headers. */

Expand All @@ -16,6 +16,8 @@

#define FLANG_VERSION "${FLANG_VERSION}"

#define FLANG_DEFAULT_LINKER "${FLANG_DEFAULT_LINKER}"

#endif


2 changes: 1 addition & 1 deletion flang/test/Driver/linker-flags.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
! MINGW-SAME: -lflang_rt.runtime
! MINGW-STATIC-FLANGRT: "{{.*}}{{\\|/}}libflang_rt.runtime.a"

! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
! NOTE: This also matches lld-link (when FLANG_DEFAULT_LINKER=lld) and
! any .exe suffix that is added when resolving to the full path of
! (lld-)link.exe on Windows platforms. The suffix may not be added
! when the executable is not found or on non-Windows platforms.
Expand Down
2 changes: 2 additions & 0 deletions flang/tools/flang-driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//===----------------------------------------------------------------------===//

#include "clang/Driver/Driver.h"
#include "flang/Config/config.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Basic/Diagnostic.h"
Expand Down Expand Up @@ -138,6 +139,7 @@ int main(int argc, const char **argv) {
llvm::sys::getDefaultTargetTriple(), diags,
"flang LLVM compiler");
theDriver.setTargetAndMode(targetandMode);
theDriver.setPreferredLinker(FLANG_DEFAULT_LINKER);
#ifdef FLANG_RUNTIME_F128_MATH_LIB
theDriver.setFlangF128MathLibrary(FLANG_RUNTIME_F128_MATH_LIB);
#endif
Expand Down