summaryrefslogtreecommitdiff
path: root/xmake/toolchains
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-03 22:37:53 +0800
committerruki <[email protected]>2025-12-03 22:37:53 +0800
commitea947a6740898e512bd0d805b9ab5735fec691db (patch)
treeabe7453725f4a13b064c032f12ccdc35ac9165b8 /xmake/toolchains
parent605ce1f6bcfa8bcbe1a1f8151361f2539fb09727 (diff)
add flang support
Diffstat (limited to 'xmake/toolchains')
-rw-r--r--xmake/toolchains/flang/xmake.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/xmake/toolchains/flang/xmake.lua b/xmake/toolchains/flang/xmake.lua
new file mode 100644
index 000000000..72eb45258
--- /dev/null
+++ b/xmake/toolchains/flang/xmake.lua
@@ -0,0 +1,56 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, Xmake Open Source Community.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define toolchain
+toolchain("flang")
+
+ -- set homepage
+ set_homepage("https://flang.llvm.org/")
+ set_description("LLVM Fortran Compiler")
+
+ -- mark as standalone toolchain
+ set_kind("standalone")
+
+ -- set toolset
+ set_toolset("fc", "$(env FC)", "flang")
+ set_toolset("fcld", "$(env FC)", "flang")
+ set_toolset("fcsh", "$(env FC)", "flang")
+ set_toolset("ar", "llvm-ar", "ar")
+
+ -- on check
+ on_check(function (toolchain)
+ return import("lib.detect.find_tool")("flang", {program = "flang"})
+ end)
+
+ -- on load
+ on_load(function (toolchain)
+ local march
+ if toolchain:is_arch("x86_64", "x64", "arm64") then
+ march = "-m64"
+ elseif toolchain:is_arch("i386", "x86", "i686") then
+ march = "-m32"
+ end
+ if march then
+ toolchain:add("fcflags", march)
+ toolchain:add("fcshflags", march)
+ toolchain:add("fcldflags", march)
+ end
+ end)
+