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

flang: support OpenMP, use shared libs on Linux #204626

Merged
merged 2 commits into from
Jan 18, 2025
Merged
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
9 changes: 8 additions & 1 deletion Formula/f/flang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ def flang_driver
end

def install
# Generate omp_lib.h and omp_lib.F90 to be used by flang build
system "cmake", "-S", "openmp", "-B", "build/projects/openmp", *std_cmake_args

llvm = Formula["llvm"]
# NOTE: Setting `BUILD_SHARED_LIBRARIES=ON` causes the just-built flang to throw ICE.
args = %W[
-DLLVM_TOOL_OPENMP_BUILD=ON
-DCLANG_DIR=#{llvm.opt_lib}/cmake/clang
-DFLANG_INCLUDE_TESTS=OFF
-DFLANG_REPOSITORY_STRING=#{tap&.issues_url}
Expand All @@ -46,6 +49,8 @@ def install
-DMLIR_DIR=#{llvm.opt_lib}/cmake/mlir
]
args << "-DFLANG_VENDOR_UTI=sh.brew.flang" if tap&.official?
# FIXME: Setting `BUILD_SHARED_LIBS=ON` causes the just-built flang to throw ICE on macOS
args << "-DBUILD_SHARED_LIBS=ON" if OS.linux?

ENV.append_to_cflags "-ffat-lto-objects" if OS.linux? # Unsupported on macOS.
system "cmake", "-S", "flang", "-B", "build", *args, *std_cmake_args
Expand Down Expand Up @@ -127,6 +132,8 @@ def caveats
system bin/flang_driver, "-v", "test.f90", "-o", "test"
assert_equal "Done", shell_output("./test").chomp

return if OS.linux?

system "ar", "x", lib/"libFortranCommon.a"
testpath.glob("*.o").each do |object_file|
refute_match(/^LLVM (IR )?bitcode/, shell_output("file --brief #{object_file}"))
Expand Down
Loading