Skip to content

Commit

Permalink
openbsd和netbsd也用clang
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Mar 26, 2023
1 parent a6f96db commit 172b110
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
7 changes: 4 additions & 3 deletions compile/ninja/netbsd.ninja
Expand Up @@ -2,7 +2,7 @@ ninja_required_version = 1.7
builddir = build/netbsd
bin = $builddir/bin
obj = $builddir/obj
cc = gcc
cc = clang
luamake = luamake
rule c_source_bee
command = $cc -MMD -MT $out -MF $out.d -O2 -Wall -Werror $
Expand Down Expand Up @@ -78,7 +78,7 @@ rule c_source_lua
build $obj/source_lua/utf8_crt.obj: c_source_lua bee.lua/3rd/lua/utf8_crt.c
rule c_source_lua_1
command = $cc -MMD -MT $out -MF $out.d -O2 -Wall -Werror -DMAKE_LIB $
-DLUA_USE_LINUX -DNDEBUG -Wno-maybe-uninitialized -o $out -c $in
-DLUA_USE_LINUX -DNDEBUG -o $out -c $in
description = Compile C $out
deps = gcc
depfile = $out.d
Expand All @@ -97,7 +97,8 @@ build $obj/source_bootstrap/progdir.obj: cxx_source_bootstrap $
bee.lua/bootstrap/progdir.cpp
rule link_bootstrap
command = $cc $in -o $out -Wl,-E -lm -l:libinotify.a -L/usr/pkg/lib $
-pthread -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -static-libgcc -s
-pthread -Wl,--push-state,-Bstatic -lstdc++ -Wl,--pop-state $
-static-libgcc -Wl,-S,-x
description = Link Exe $out
build $bin/bootstrap: link_bootstrap $obj/source_bootstrap/main.obj $
$obj/source_bootstrap/progdir.obj $obj/source_bee/lua-seri.obj $
Expand Down
8 changes: 4 additions & 4 deletions compile/ninja/openbsd.ninja
Expand Up @@ -2,7 +2,7 @@ ninja_required_version = 1.7
builddir = build/openbsd
bin = $builddir/bin
obj = $builddir/obj
cc = egcc
cc = clang
luamake = luamake
rule c_source_bee
command = $cc -MMD -MT $out -MF $out.d -O2 -Wall -Werror $
Expand Down Expand Up @@ -78,7 +78,7 @@ rule c_source_lua
build $obj/source_lua/utf8_crt.obj: c_source_lua bee.lua/3rd/lua/utf8_crt.c
rule c_source_lua_1
command = $cc -MMD -MT $out -MF $out.d -O2 -Wall -Werror -DMAKE_LIB $
-DLUA_USE_LINUX -DNDEBUG -Wno-maybe-uninitialized -o $out -c $in
-DLUA_USE_LINUX -DNDEBUG -o $out -c $in
description = Compile C $out
deps = gcc
depfile = $out.d
Expand All @@ -97,8 +97,8 @@ build $obj/source_bootstrap/progdir.obj: cxx_source_bootstrap $
bee.lua/bootstrap/progdir.cpp
rule link_bootstrap
command = $cc $in -o $out -Wl,-E -lm -l:libinotify.a $
-L/usr/local/lib/inotify -pthread -Wl,-Bstatic -lestdc++ -Wl,-Bdynamic $
-static-libgcc -s
-L/usr/local/lib/inotify -pthread -Wl,--push-state,-Bstatic -lstdc++ $
-Wl,--pop-state -static-libgcc -Wl,-S,-x
description = Link Exe $out
build $bin/bootstrap: link_bootstrap $obj/source_bootstrap/main.obj $
$obj/source_bootstrap/progdir.obj $obj/source_bee/lua-seri.obj $
Expand Down
4 changes: 2 additions & 2 deletions scripts/compiler/gcc.lua
Expand Up @@ -84,10 +84,10 @@ function gcc.update_ldflags(ldflags, attribute)
--TODO android不支持static crt
ldflags[#ldflags+1] = "-lstdc++"
elseif attribute.crt == "dynamic" then
ldflags[#ldflags+1] = globals.os == "openbsd" and "-lestdc++" or "-lstdc++"
ldflags[#ldflags+1] = "-lstdc++"
else
ldflags[#ldflags+1] = "-Wl,-Bstatic"
ldflags[#ldflags+1] = globals.os == "openbsd" and "-lestdc++" or "-lstdc++"
ldflags[#ldflags+1] = "-lstdc++"
ldflags[#ldflags+1] = "-Wl,-Bdynamic"
ldflags[#ldflags+1] = "-static-libgcc"
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/globals.lua
Expand Up @@ -22,7 +22,7 @@ end)()
globals.compiler = globals.compiler or (function()
if globals.hostshell == "cmd" then
return "msvc"
elseif globals.hostos == "macos" or globals.hostos == "freebsd" then
elseif globals.hostos == "macos" or globals.hostos == "freebsd" or globals.hostos == "openbsd" or globals.hostos == "netbsd" then
return "clang"
end
return "gcc"
Expand Down
6 changes: 1 addition & 5 deletions scripts/writer.lua
Expand Up @@ -986,11 +986,7 @@ function m.generate()
if globals.hostshell == "cmd" then
compiler = 'cmd /c '..compiler
end
if globals.os == "openbsd" and compiler == "gcc" then
ninja:variable("cc", "egcc")
else
ninja:variable("cc", compiler)
end
ninja:variable("cc", compiler)
end

if globals.prebuilt then
Expand Down

0 comments on commit 172b110

Please sign in to comment.