Skip to content

Commit

Permalink
Upgraded to clang++ 17
Browse files Browse the repository at this point in the history
  • Loading branch information
ruoka committed Sep 24, 2023
1 parent 0cc6797 commit e3315ea
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
.SUFFIXES:
.SUFFIXES: .cpp .hpp .c++ .c++m .impl.c++ .test.c++ .o .impl.o .test.o
.SUFFIXES: .cpp .hpp .c++ .c++m .impl.c++ .test.c++ .o .impl.o .test.o
.DEFAULT_GOAL = all

ifndef OS
OS = $(shell uname -s)
endif

ifeq ($(OS),Linux)
CC = /usr/lib/llvm-15/bin/clang
CXX = /usr/lib/llvm-15/bin/clang++
CXXFLAGS = -pthread -I/usr/lib/llvm-15/include/c++/v1
LDFLAGS = -lc++ -lc++experimental -L/usr/lib/llvm-15/lib/c++
CC = /usr/lib/llvm-17/bin/clang
CXX = /usr/lib/llvm-17/bin/clang++
CXXFLAGS = -pthread -I/usr/lib/llvm-17/include/c++/v1
LDFLAGS = -lc++ -L/usr/lib/llvm-17/lib/c++
endif

ifeq ($(OS),Darwin)
CC = /opt/homebrew/opt/llvm/bin/clang
CXX = /opt/homebrew/opt/llvm/bin/clang++
CXXFLAGS =-I/opt/homebrew/opt/llvm/include/c++/v1
LDFLAGS = -L/opt/homebrew/opt/llvm/lib/c++
LDFLAGS = -L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++
endif

ifeq ($(OS),Github)
Expand All @@ -27,11 +27,15 @@ CXXFLAGS = -I/usr/local/opt/llvm/include/ -I/usr/local/opt/llvm/include/c++/v1
LDFLAGS = -L/usr/local/opt/llvm/lib/c++ -Wl,-rpath,/usr/local/opt/llvm/lib/c++
endif

CXXFLAGS += -std=c++20 -stdlib=libc++ -fexperimental-library
CXXFLAGS += -fprebuilt-module-path=$(moduledir)
CXXFLAGS += -std=c++20 -stdlib=libc++
CXXFLAGS += -Wall -Wextra
CXXFLAGS += -I$(sourcedir) -I$(includedir)
LDFLAGS += -fuse-ld=lld -fexperimental-library
LDFLAGS += -fuse-ld=lld

PCMFLAGS += -fno-implicit-modules -fno-implicit-module-maps
PCMFLAGS += -fmodule-file=std=./pcm/std.pcm -fmodule-file=net=./pcm/net.pcm -fmodule-file=xson=./pcm/xson.pcm
PCMFLAGS += $(foreach P, $(foreach M, $(modules), $(basename $(notdir $(M)))), -fmodule-file=$(subst -,:,$(P))=./pcm/$(P).pcm)
CXXFLAGS += $(PCMFLAGS)

export CC
export CXX
Expand Down Expand Up @@ -67,12 +71,11 @@ $(moduledir)/%.pcm: $(sourcedir)/%.c++m

$(objectdir)/%.o: $(moduledir)/%.pcm
@mkdir -p $(@D)
$(CXX) $< -c -o $@
$(CXX) $(PCMFLAGS) $< -c -o $@

$(objectdir)/%.impl.o: $(sourcedir)/%.impl.c++
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $< -fmodule-file=$(moduledir)/yar.pcm -c -o $@
# $(CXX) $(CXXFLAGS) $< -fmodule-file=$(objectdir)/$(basename $(basename $(@F))).pcm -c -o $@
$(CXX) $(CXXFLAGS) $< -fmodule-file=$(basename $(basename $(@F)))=$(moduledir)/$(basename $(basename $(@F))).pcm -c -o $@

$(objectdir)/%.test.o: $(sourcedir)/%.test.c++
@mkdir -p $(@D)
Expand Down
2 changes: 1 addition & 1 deletion json4cpp
Submodule json4cpp updated 1 files
+1 −1 Makefile
2 changes: 1 addition & 1 deletion net4cpp
2 changes: 1 addition & 1 deletion std
Submodule std updated 2 files
+0 −3 Makefile
+32 −30 src/std.c++m
6 changes: 3 additions & 3 deletions yar/yardb.c++
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ try
const auto arguments = span(argv,argc).subspan(1);
auto file = "yar.db"s;
auto service_or_port = "2112"s;
slog.tag("YarDB");
slog.appname("YarDB");
slog.level(net::syslog::severity::debug);

for(string_view option : arguments)
Expand All @@ -29,12 +29,12 @@ try
else if(option.starts_with("--slog_tag="))
{
option.remove_prefix(option.find_first_not_of("--slog_tag="));
slog.tag(option);
slog.appname(option);
}
else if(option.starts_with("--slog_level="))
{
option.remove_prefix(option.find_first_not_of("--slog_level="));
auto mask = 0;
auto mask = 0u;
auto [ptr,ec] = std::from_chars(option.begin(),option.end(),mask);
if(ec != std::errc() or ptr != option.end())
{
Expand Down
14 changes: 7 additions & 7 deletions yar/yarproxy.c++
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ inline void handle(auto& client, auto& replicas)
if(method == "GET"s || method == "HEAD"s)
{
const auto lock = ext::make_lock(replicas);
ranges::any_of(replicas, request_and_response);
ranges::rotate(replicas, ++ranges::begin(replicas));
[[maybe_unused]] auto r1 = ranges::any_of(replicas, request_and_response);
[[maybe_unused]] auto r2 = ranges::rotate(replicas, ++ranges::begin(replicas));
}
else
{
const auto lock = ext::make_lock(replicas);
ranges::all_of(replicas, request);
ranges::all_of(replicas, response);
[[maybe_unused]] auto r1 = ranges::all_of(replicas, request);
[[maybe_unused]] auto r2 = ranges::all_of(replicas, response);
}

buffer.seekg(0) >> stream;
Expand All @@ -94,7 +94,7 @@ try
const auto arguments = span(argv,argc).subspan(1);
auto replicas = replica_set{};
auto service_or_port = "2113"s;
slog.tag("YarPROXY");
slog.appname("YarPROXY");
slog.level(net::syslog::severity::debug);

for(string_view option : arguments)
Expand All @@ -106,12 +106,12 @@ try
else if(option.starts_with("--slog_tag="))
{
option.remove_prefix(option.find_first_not_of("--slog_tag="));
slog.tag(option);
slog.appname(option);
}
else if(option.starts_with("--slog_level="))
{
option.remove_prefix(option.find_first_not_of("--slog_level="));
auto mask = 0;
auto mask = 0u;
auto [ptr,ec] = std::from_chars(option.begin(),option.end(),mask);
if(ec != std::errc() or ptr != option.end())
{
Expand Down

0 comments on commit e3315ea

Please sign in to comment.