Skip to content

Commit

Permalink
refactor: bundle boost 1.83.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 30, 2023
1 parent 90bd22d commit fa3d4ea
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ third-party/cryptopp-CRYPTOPP_7_0_0
third-party/downloads
third-party/grpc
third-party/mongoose-*
src/remote-cartesi-machine-proxy
third-party/boost_*
src/remote-cartesi-machine
src/jsonrpc-remote-cartesi-machine
src/merkle-tree-hash
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ARG SANITIZE=no
RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
build-essential vim wget git clang-tidy-15 clang-format-15 lcov \
libreadline-dev libboost-filesystem1.81-dev libssl-dev libc-ares-dev zlib1g-dev \
ca-certificates automake libtool patchelf cmake pkg-config lua5.4 liblua5.4-dev \
libssl-dev \
ca-certificates automake libtool patchelf pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks libcrypto++-dev && \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 120 && \
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ EMU_TO_INC= $(addprefix lib/machine-emulator-defines/,pma-defines.h rtc-defines.
UARCH_TO_SHARE= uarch-ram.bin

MONGOOSE_VERSION=7.12
BOOST_VERSION=1_83_0

# Build settings
DEPDIR := third-party
SRCDIR := $(abspath src)
DOWNLOADDIR := $(DEPDIR)/downloads
DEPDIRS := third-party/mongoose-$(MONGOOSE_VERSION)
DEPDIRS := third-party/mongoose-$(MONGOOSE_VERSION) third-party/boost_$(BOOST_VERSION)
SUBCLEAN := $(addsuffix .clean,$(SRCDIR) uarch third-party/riscv-arch-tests)
COREPROTO := lib/grpc-interfaces/core.proto

Expand Down Expand Up @@ -170,6 +171,10 @@ third-party/downloads/$(MONGOOSE_VERSION).tar.gz: | downloads
third-party/mongoose-$(MONGOOSE_VERSION): third-party/downloads/$(MONGOOSE_VERSION).tar.gz
tar -C third-party -xzf $< mongoose-$(MONGOOSE_VERSION)/mongoose.c mongoose-$(MONGOOSE_VERSION)/mongoose.h

third-party/downloads/boost_$(BOOST_VERSION).tar.gz: | downloads
third-party/boost_$(BOOST_VERSION): third-party/downloads/boost_$(BOOST_VERSION).tar.gz
tar -C third-party -xzf $< boost_$(BOOST_VERSION)/boost

dep: $(DEPDIRS)

submodules:
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ Docker targets:
- Cryptopp >= 7.0.0
- GRPC >= 1.45.0
- Lua >= 5.4.4
- Boost >= 1.81

Obs: Please note that Apple Clang Version number does not follow upstream LLVM/Clang.

#### Debian Bookworm

```
apt-get install build-essential wget git clang-tidy-15 clang-format-15 \
libreadline-dev libboost-context1.81-dev \
libboost-filesystem1.81-dev libssl-dev libc-ares-dev zlib1g-dev \
ca-certificates automake libtool patchelf cmake pkg-config lua5.4 liblua5.4-dev \
libssl-dev \
ca-certificates automake libtool patchelf pkg-config lua5.4 liblua5.4-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
luarocks libcrypto++-dev
Expand All @@ -48,7 +46,7 @@ sudo luarocks install --lua-version=5.4 luaposix

##### MacPorts
```
sudo port install clang-15 automake boost libtool wget cmake pkgconfig grpc zlib openssl lua libcryptopp lua-luarocks
sudo port install clang-15 automake libtool wget pkgconfig grpc openssl lua libcryptopp lua-luarocks
sudo luarocks install --lua-version=5.4 lpeg
sudo luarocks install --lua-version=5.4 dkjson
Expand All @@ -59,7 +57,7 @@ sudo luarocks install --lua-version=5.4 luaposix

##### Homebrew
```
brew install llvm@15 automake boost libomp wget cmake cryptopp pkg-config grpc zlib openssl [email protected] luarocks
brew install llvm@15 automake wget cryptopp pkg-config grpc openssl [email protected] luarocks
luarocks --lua-dir=$(brew --prefix)/opt/[email protected] install lpeg
luarocks --lua-dir=$(brew --prefix)/opt/[email protected] install dkjson
luarocks --lua-dir=$(brew --prefix)/opt/[email protected] install luasocket
Expand Down
20 changes: 6 additions & 14 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ SOLDFLAGS_Darwin+=-Wl,-rpath,$(CURDIR)
# Homebrew installation
ifneq (,$(shell which brew))
BREW_PREFIX := $(shell brew --prefix)
BOOST_LIB_DIR_Darwin=-L$(BREW_PREFIX)/lib
BOOST_INC_Darwin=-I$(BREW_PREFIX)/include
CRYPTOPP_LIB_Darwin:=-L$(BREW_PREFIX)/lib -lcryptopp
CRYPTOPP_INC_Darwin:=-I$(BREW_PREFIX)/include
GRPC_INC_Darwin:=$(shell pkg-config --cflags-only-I grpc++)
Expand All @@ -72,8 +70,6 @@ PROTOBUF_INC_Darwin:=$(shell pkg-config --cflags-only-I protobuf)
PROTOBUF_LIB_Darwin:=$(shell pkg-config --libs protobuf)
else ifneq (,$(shell which port)) # Macports installation
PORT_PREFIX := /opt/local
BOOST_LIB_DIR_Darwin=-L$(PORT_PREFIX)/libexec/boost/1.81/lib
BOOST_INC_Darwin=-I$(PORT_PREFIX)/libexec/boost/1.81/include
CRYPTOPP_LIB_Darwin:=-L$(PORT_PREFIX)/lib -lcryptopp
CRYPTOPP_INC_Darwin:=-I$(PORT_PREFIX)/include
GRPC_INC_Darwin:=-I$(PORT_PREFIX)/include
Expand All @@ -85,8 +81,7 @@ $(error Neither Homebrew nor MacPorts is installed)
endif
endif

BOOST_FILESYSTEM_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_system-mt -lboost_filesystem-mt
BOOST_PROCESS_LIB_Darwin:=-lpthread
PTHREAD_LIB_Darwin:=-lpthread
LIBCARTESI_Darwin=libcartesi-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).dylib
LIBCARTESI_LDFLAGS_Darwin=-dynamiclib -undefined dynamic_lookup -install_name '@rpath/$(LIBCARTESI_Darwin)'
LIBCARTESI_TESTS_LDFLAGS_Darwin=-Wl,-rpath,$(CURDIR)
Expand All @@ -105,9 +100,7 @@ CC_Linux=gcc
CXX_Linux=g++
INCS_Linux=
FS_LIB_Linux=-lstdc++fs
BOOST_FILESYSTEM_LIB_Linux:=-lboost_system -lboost_filesystem
BOOST_PROCESS_LIB_Linux:=-lpthread
BOOST_INC_Linux=
PTHREAD_LIB_Linux:=-lpthread
CRYPTOPP_LIB_Linux:=-lcryptopp
CRYPTOPP_INC_Linux:=
GRPC_INC_Linux:=$(shell pkg-config --cflags-only-I grpc++)
Expand All @@ -129,9 +122,7 @@ PROFILE_DATA_Linux=
CC=$(CC_$(UNAME))
CXX=$(CXX_$(UNAME))
SOLDFLAGS:=$(SOLDFLAGS_$(UNAME)) $(GCLDFLAGS)
BOOST_PROCESS_LIB=$(BOOST_PROCESS_LIB_$(UNAME))
BOOST_FILESYSTEM_LIB=$(BOOST_FILESYSTEM_LIB_$(UNAME))
BOOST_INC=$(BOOST_INC_$(UNAME))
PTHREAD_LIB=$(PTHREAD_LIB_$(UNAME))
CRYPTOPP_LIB=$(CRYPTOPP_LIB_$(UNAME))
CRYPTOPP_INC=$(CRYPTOPP_INC_$(UNAME))
GRPC_INC:=$(GRPC_INC_$(UNAME))
Expand All @@ -156,7 +147,7 @@ LUACARTESI_GRPC_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB) $(LIBCARTESI_GRPC_LIB)
LUACARTESI_JSONRPC_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB)
REMOTE_CARTESI_MACHINE_LIBS:=$(CRYPTOPP_LIB) $(GRPC_LIB) $(PROTOBUF_LIB)
JSONRPC_REMOTE_CARTESI_MACHINE_LIBS:=$(CRYPTOPP_LIB)
TEST_MACHINE_C_API_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB) $(LIBCARTESI_GRPC_LIB) $(BOOST_PROCESS_LIB) $(BOOST_FILESYSTEM_LIB)
TEST_MACHINE_C_API_LIBS:=$(LIBCARTESI_LIB) $(CRYPTOPP_LIB) $(LIBCARTESI_GRPC_LIB) $(PTHREAD_LIB)
HASH_LIBS:=$(CRYPTOPP_LIB)

#DEFS+= -DMT_ALL_DIRTY
Expand All @@ -169,7 +160,8 @@ INCS= \
-I../third-party/llvm-flang-uint128 \
-I../third-party/downloads \
-I../third-party/mongoose-7.12 \
$(LUA_INC) $(CRYPTOPP_INC) $(BOOST_INC) $(PROTOBUF_INC) $(GRPC_INC) $(INCS_$(UNAME))
-I../third-party/boost_1_83_0 \
$(LUA_INC) $(CRYPTOPP_INC) $(PROTOBUF_INC) $(GRPC_INC) $(INCS_$(UNAME))

ifeq ($(dump),yes)
#DEFS+=-DDUMP_ILLEGAL_INSN_EXCEPTIONS
Expand Down
21 changes: 13 additions & 8 deletions src/test-machine-c-api.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#define BOOST_TEST_MODULE Machine C API test // NOLINT(cppcoreguidelines-macro-usage)
#define BOOST_TEST_NO_OLD_TOOLS

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wdangling-reference"
#include <boost/endian/conversion.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/process.hpp>
#include <boost/process/search_path.hpp>
#include <boost/test/included/unit_test.hpp>
Expand Down Expand Up @@ -424,8 +427,7 @@ std::ostream &boost_test_print_type(std::ostream &ostr, const cm_machine_config
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class serialized_machine_fixture : public ordinary_machine_fixture {
public:
serialized_machine_fixture() :
_machine_config_path{boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()} {
serialized_machine_fixture() : _machine_config_path{std::filesystem::temp_directory_path() / "machine"} {
char *err_msg{};
int error_code = cm_store(_machine, _machine_config_path.string().c_str(), &err_msg);
BOOST_CHECK_EQUAL(error_code, CM_ERROR_OK);
Expand All @@ -437,7 +439,7 @@ class serialized_machine_fixture : public ordinary_machine_fixture {
}

protected:
boost::filesystem::path _machine_config_path;
std::filesystem::path _machine_config_path;

auto _load_config() const {
std::ifstream ifs(_config_dir(), std::ios::binary);
Expand Down Expand Up @@ -478,8 +480,7 @@ BOOST_FIXTURE_TEST_CASE_NOLINT(load_machine_invalid_config_version_test, seriali

class store_file_fixture : public ordinary_machine_fixture {
public:
store_file_fixture() :
_broken_machine_path{(boost::filesystem::temp_directory_path() / boost::filesystem::unique_path()).string()} {}
store_file_fixture() : _broken_machine_path{(std::filesystem::temp_directory_path() / "machine").string()} {}

~store_file_fixture() {
std::filesystem::remove_all(_broken_machine_path);
Expand Down Expand Up @@ -2462,7 +2463,11 @@ static bool wait_for_server(cm_grpc_machine_stub *stub, int retries = 10) {
class grpc_machine_fixture_with_server : public grpc_machine_fixture {
public:
grpc_machine_fixture_with_server() {
boost::process::spawn(boost::process::search_path("remote-cartesi-machine"), "127.0.0.1:5001", m_server_group);
auto process_path = std::filesystem::current_path() / "remote-cartesi-machine";
if (!std::filesystem::exists(process_path)) {
process_path = "/usr/bin/remote-cartesi-machine";
}
boost::process::spawn(process_path.string(), "127.0.0.1:5001", m_server_group);
BOOST_CHECK(wait_for_server(m_stub));
}
~grpc_machine_fixture_with_server() override = default;
Expand Down
1 change: 1 addition & 0 deletions third-party/dependencies
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
https://github.com/cesanta/mongoose/archive/refs/tags/7.12.tar.gz
https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.gz
https://github.com/nlohmann/json/releases/download/v3.11.2/json.hpp
1 change: 1 addition & 0 deletions third-party/shasumfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fe939f7f6d7adb76480a0fe593e66b9a6cc9ad55 downloads/7.12.tar.gz
eb5e17350b5ccd5926fd6bad9f09385c742a3352 downloads/boost_1_83_0.tar.gz
ce36f0cfc3ebba05259186ad6fd2233e14e0e698 downloads/json.hpp
2 changes: 1 addition & 1 deletion tools/template/control.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Homepage: https://docs.cartesi.io/machine/host/cmdline/
Architecture: ARG_ARCH
Maintainer: Machine Reference Unit <https://discord.com/channels/600597137524391947/1107965671976992878>
Provides: machine-emulator
Depends: libboost-context1.81.0, libboost-filesystem1.81.0, libreadline8, openssl, libc-ares2, zlib1g, ca-certificates, libgomp1, lua5.4, libcrypto++8, libprotobuf32, libgrpc++1.51
Depends: lua5.4, libcrypto++8, libprotobuf32, libgrpc++1.51
Section: devel
Priority: optional
Multi-Arch: foreign
Expand Down
10 changes: 1 addition & 9 deletions uarch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ EMULATOR_SRC_DIR = ../src
MACHINE_EMULATOR_DEFINES_DIR := ../lib/machine-emulator-defines
THIRD_PARTY_DIR := ../third-party

BOOST_INC_DIR = /usr/include/boost
ifeq ($(UNAME),Darwin)
# Homebrew installation
ifneq (,$(wildcard /usr/local/opt/boost/lib))
BOOST_INC_DIR =/usr/local/opt/boost/include
else # Macports installation
BOOST_INC_DIR = /opt/local/include
endif
endif
BOOST_INC_DIR = ../third-party/boost_1_83_0

CC := $(TOOLCHAIN_PREFIX)gcc
LD := $(TOOLCHAIN_PREFIX)ld
Expand Down

0 comments on commit fa3d4ea

Please sign in to comment.