Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 16 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,11 @@ endif
endif

#Allow user specify non-default location of boost
# Note: boost::system became fully header-only in Boost 1.78. libboost_system.a
# is no longer generated by modern Boost builds. The OSv kernel only uses
# boost::system for error_code which is entirely in headers; no symbols need
# to be linked. We detect the library if present (for older Boost) but do not
# require it (for Boost 1.78+).
ifeq ($(boost_base),)
# link with -mt if present, else the base version (and hope it is multithreaded)
boost-mt := -mt
Expand All @@ -2145,7 +2150,8 @@ ifeq ($(boost_base),)
boost-includes =
ifeq ($(filter /%,$(boost-lib-dir)),)
# If the compiler cannot find the boost library, for aarch64 we look in a
# special location before giving up.
# special location. For modern Boost (1.78+) libboost_system.a does not
# exist; we proceed without it since boost::system is header-only.
ifeq ($(arch),aarch64)
aarch64_boostbase = build/downloaded_packages/aarch64/boost/install
ifeq (,$(wildcard $(aarch64_boostbase)))
Expand All @@ -2155,18 +2161,22 @@ ifeq ($(boost_base),)
boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a)))
boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
boost-includes = -isystem $(aarch64_boostbase)/usr/include
else
$(error Error: libboost_system.a needs to be installed.)
# else: modern Boost >= 1.78 on x86_64 - libboost_system.a is not needed
endif
endif
else
# Use boost specified by the user
boost-lib-dir := $(firstword $(dir $(shell find $(boost_base)/ -name libboost_system*.a)))
boost-lib-dir := $(firstword $(dir $(shell find $(boost_base)/ -name libboost_system*.a 2>/dev/null)))
boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt)
boost-includes = -isystem $(boost_base)/usr/include
# Support both layouts: nixpkgs places headers in $boost_base/include,
# legacy/FHS packages place them in $boost_base/usr/include.
boost-inc-dir := $(firstword $(wildcard $(boost_base)/include) $(wildcard $(boost_base)/usr/include))
boost-includes = $(if $(boost-inc-dir),-isystem $(boost-inc-dir),)
endif

boost-libs := $(boost-lib-dir)/libboost_system$(boost-mt).a
# Only link libboost_system.a if it actually exists (Boost < 1.78).
# Modern Boost (>= 1.78) dropped the compiled library; all functionality is in headers.
boost-libs := $(wildcard $(boost-lib-dir)/libboost_system$(boost-mt).a)

objects += fs/nfs/nfs_null_vfsops.o
objects += fs/ext/ext_null_vfsops.o
Expand Down
2 changes: 1 addition & 1 deletion conf/base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ conf_logger_debug=0
conf_debug_elf=0
conf_hide_symbols=0
conf_linker_extra_options=
conf_cxx_level=gnu++11
conf_cxx_level=gnu++14

conf_lazy_stack=0
conf_lazy_stack_invariant=0
10 changes: 5 additions & 5 deletions core/dhcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ u8 requested_options[] = {
dhcp::DHCP_OPTION_HOSTNAME
};

const ip::address_v4 ipv4_zero = ip::address_v4::address_v4::from_string("0.0.0.0");
const ip::address_v4 ipv4_zero = ip::make_address_v4("0.0.0.0");

// Returns whether we hooked the packet
int dhcp_hook_rx(struct mbuf* m)
Expand Down Expand Up @@ -239,8 +239,8 @@ namespace dhcp {
pkt->secs = 0;
pkt->flags = 0;
memcpy(pkt->chaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN);
ulong yip_n = htonl(yip.to_ulong());
ulong sip_n = htonl(sip.to_ulong());
ulong yip_n = htonl(yip.to_uint());
ulong sip_n = htonl(sip.to_uint());
if(request_packet_type == DHCP_REQUEST_RENEWING || request_packet_type == DHCP_REQUEST_REBINDING) {
// ciaddr should only be set to if RENEWING or REBINDING
// See pages 21 and 30-31 in https://www.ietf.org/rfc/rfc2131.txt
Expand Down Expand Up @@ -299,8 +299,8 @@ namespace dhcp {
pkt->secs = 0;
pkt->flags = 0;
memcpy(pkt->chaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN);
ulong yip_n = htonl(yip.to_ulong());
ulong sip_n = htonl(sip.to_ulong());
ulong yip_n = htonl(yip.to_uint());
ulong sip_n = htonl(sip.to_uint());
memcpy(&pkt->ciaddr.s_addr, &yip_n, 4);

// Options
Expand Down
1 change: 1 addition & 0 deletions core/mmu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "dump.hh"
#include <osv/rcu.hh>
#include <osv/rwlock.h>
#include <algorithm>
#include <numeric>
#include <set>

Expand Down
1 change: 1 addition & 0 deletions core/pagecache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <unordered_set>
#include <deque>
#include <stack>
#include <algorithm>
#include <boost/variant.hpp>
#include <osv/pagecache.hh>
#include <osv/mempool.hh>
Expand Down
4 changes: 2 additions & 2 deletions loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ void* do_main_thread(void *_main_args)
opt_defaultgw.c_str());
}
if (opt_nameserver.size() != 0) {
auto addr = boost::asio::ip::address_v4::from_string(opt_nameserver);
osv::set_dns_config({addr}, std::vector<std::string>());
auto addr = boost::asio::ip::make_address_v4(opt_nameserver);
osv::set_dns_config({boost::asio::ip::address(addr)}, std::vector<std::string>());
}
#if CONF_networking_dhcp
}
Expand Down
2 changes: 1 addition & 1 deletion modules/cloud-init/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void client::set_header(const std::string& name, const std::string& value)
}

template<typename Duration>
static void connect_with_timeout(boost::asio::io_service& io_service,
static void connect_with_timeout(boost::asio::io_context& io_service,
boost::asio::ip::tcp::socket& _socket, tcp::endpoint& _endpoint,
boost::system::error_code& ec, Duration duration)
{
Expand Down
2 changes: 1 addition & 1 deletion modules/cloud-init/client.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private:
void process_headers();
boost::asio::streambuf response;
unsigned int status_code;
boost::asio::io_service io_service;
boost::asio::io_context io_service;
boost::asio::ip::tcp::socket _socket;
bool done = false;
std::unordered_map<std::string, std::string> _headers;
Expand Down
19 changes: 15 additions & 4 deletions modules/common.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ makedir = $(call very-quiet, mkdir -p $(dir $@))
autodepend = -MD -MT $@ -MP

ifeq ($(conf_cxx_level),)
conf_cxx_level=gnu++11
conf_cxx_level=gnu++14
endif

# By default, detect HOST_CXX's architecture - x64 or aarch64.
Expand Down Expand Up @@ -155,9 +155,20 @@ else
absolute_boost_base := $(boost_base)# It is absolute already
endif
# Use boost specified by the user
boost-lib-dir := $(firstword $(dir $(shell find $(absolute_boost_base)/ -name libboost_system.so)))
LDFLAGS += -L$(boost-lib-dir)
boost-includes = -isystem $(absolute_boost_base)/usr/include
# boost::system is header-only since Boost 1.78; libboost_system.so may not exist.
# boost_lib_dir can be set separately (e.g. on NixOS where headers and libs are split).
ifneq ($(boost_lib_dir),)
boost-lib-dir := $(boost_lib_dir)
else
boost-lib-dir := $(firstword $(dir $(shell find $(absolute_boost_base)/ -name libboost_filesystem.so)))
endif
ifneq ($(boost-lib-dir),)
LDFLAGS += -L$(boost-lib-dir)
endif
# Support both layouts: nixpkgs places headers in $boost_base/include,
# legacy/FHS packages place them in $boost_base/usr/include.
boost-inc-dir := $(firstword $(wildcard $(absolute_boost_base)/include) $(wildcard $(absolute_boost_base)/usr/include))
boost-includes = $(if $(boost-inc-dir),-isystem $(boost-inc-dir),)
endif

# Let us set INCLUDES given all paths identified above
Expand Down
3 changes: 2 additions & 1 deletion modules/httpserver-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ INCLUDES += -I. -I $(src)/libc/internal
# -Wall turns on most, but not all, compiler warnings
CXXFLAGS = -g -Wall -std=$(conf_cxx_level) -fPIC $(COMMON) -O2

boost-libs := -lboost_system -lboost_filesystem
# boost::system is header-only since Boost 1.78; link only boost_filesystem
boost-libs := -lboost_filesystem

# the build target executable:
TARGET = httpserver-api
Expand Down
2 changes: 1 addition & 1 deletion modules/httpserver-api/global_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void global_server::set_routes()
if (!fs::exists(plugin_path) && !fs::is_directory(plugin_path)) return;
BOOST_FOREACH(const fs::path& path, std::make_pair(fs::directory_iterator(plugin_path),
fs::directory_iterator())) {
if (fs::extension(path)==".so") {
if (path.extension().string()==".so") {
load_plugin(path.string());
}
}
Expand Down
6 changes: 3 additions & 3 deletions modules/httpserver-api/json/formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "formatter.hh"
#include "json_elements.hh"
#include <float.h>
#include <boost/math/special_functions/fpclassify.hpp>
#include <cmath>
#include <iomanip>

using namespace std;
Expand Down Expand Up @@ -43,9 +43,9 @@ string formatter::to_json(long n)
string formatter::to_json(float f)
{
int inf;
if ((inf = boost::math::isinf(f))) {
if ((inf = std::isinf(f))) {
f = inf * FLT_MAX;
} else if (boost::math::isnan(f)) {
} else if (std::isnan(f)) {
f = 0;
}
return to_string(f);
Expand Down
4 changes: 2 additions & 2 deletions modules/httpserver-api/plain_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class plain_transport : public transport
callback(ec);
}

void async_read_some(boost::asio::mutable_buffers_1 buf,
void async_read_some(boost::asio::mutable_buffer buf,
std::function<void(boost::system::error_code, std::size_t)>&& callback) override
{
_socket.async_read_some(buf, std::move(callback));
Expand All @@ -52,7 +52,7 @@ class plain_transport : public transport
}
};

plain_acceptor::plain_acceptor(boost::asio::io_service& io_service,
plain_acceptor::plain_acceptor(boost::asio::io_context& io_service,
tcp::acceptor&& tcp_acceptor)
: _io_service(io_service)
, _tcp_acceptor(std::move(tcp_acceptor))
Expand Down
4 changes: 2 additions & 2 deletions modules/httpserver-api/plain_server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class plain_acceptor : public acceptor
public:
using socket_t = tcp::socket;
private:
boost::asio::io_service& _io_service;
boost::asio::io_context& _io_service;
tcp::acceptor _tcp_acceptor;
socket_t _socket;
public:
plain_acceptor(boost::asio::io_service& io_service, tcp::acceptor&& tcp_acceptor);
plain_acceptor(boost::asio::io_context& io_service, tcp::acceptor&& tcp_acceptor);
void do_accept(callback_t on_connected) override;
void close() override;
};
Expand Down
10 changes: 5 additions & 5 deletions modules/httpserver-api/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ server::server(std::map<std::string,std::vector<std::string>> &config,
{
// Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
boost::asio::ip::tcp::resolver resolver(io_service_);
boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve({
options::extract_option_value(config, "ipaddress"),
options::extract_option_value(config, "port")
});
boost::asio::ip::tcp::endpoint endpoint =
resolver.resolve(
options::extract_option_value(config, "ipaddress"),
options::extract_option_value(config, "port")).begin()->endpoint();

tcp::acceptor tcp_acceptor(io_service_);
tcp_acceptor.open(endpoint.protocol());
Expand Down Expand Up @@ -112,7 +112,7 @@ void server::on_connected(std::shared_ptr<transport> t)

void server::close()
{
io_service_.dispatch([&] {
boost::asio::dispatch(io_service_, [&] {
acceptor_->close();
connection_manager_.stop_all();
io_service_.stop();
Expand Down
2 changes: 1 addition & 1 deletion modules/httpserver-api/server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private:
* The io_service used to perform asynchronous operations.
*
*/
boost::asio::io_service io_service_;
boost::asio::io_context io_service_;

/**
* Acceptor used to listen for incoming connections.
Expand Down
4 changes: 2 additions & 2 deletions modules/httpserver-api/ssl_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ssl_transport : public transport {
});
}

void async_read_some(boost::asio::mutable_buffers_1 buf,
void async_read_some(boost::asio::mutable_buffer buf,
std::function<void(boost::system::error_code, std::size_t)>&& callback) override
{
_socket->async_read_some(buf, std::move(callback));
Expand All @@ -56,7 +56,7 @@ class ssl_transport : public transport {
}
};

ssl_acceptor::ssl_acceptor(boost::asio::io_service& io_service,
ssl_acceptor::ssl_acceptor(boost::asio::io_context& io_service,
boost::asio::ssl::context&& ctx,
tcp::acceptor&& tcp_acceptor)
: _io_service(io_service)
Expand Down
4 changes: 2 additions & 2 deletions modules/httpserver-api/ssl_server.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ namespace ssl = boost::asio::ssl;
class ssl_acceptor : public acceptor
{
private:
boost::asio::io_service& _io_service;
boost::asio::io_context& _io_service;
ssl::context _ctx;
tcp::acceptor _tcp_acceptor;
public:
ssl_acceptor(boost::asio::io_service& io_service,
ssl_acceptor(boost::asio::io_context& io_service,
boost::asio::ssl::context&& ctx,
tcp::acceptor&& tcp_acceptor);

Expand Down
2 changes: 1 addition & 1 deletion modules/httpserver-api/transport.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class transport {
public:
virtual void close(std::function<void(boost::system::error_code)> callback) = 0;

virtual void async_read_some(boost::asio::mutable_buffers_1 buf,
virtual void async_read_some(boost::asio::mutable_buffer buf,
std::function<void(boost::system::error_code, std::size_t)>&& callback) = 0;

virtual void async_write(std::vector<boost::asio::const_buffer> buffers,
Expand Down
8 changes: 7 additions & 1 deletion modules/libz/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Take libz.so from the build machine and put it in the image.
very-quiet = $(if $V, $1, @$1)
libz = $(shell $(CC) -print-file-name=libz.so.1)
libz_cc = $(shell $(CC) -print-file-name=libz.so.1)
# On NixOS, CC -print-file-name returns a relative path; fall back to LD_LIBRARY_PATH search.
libz = $(if $(filter /%,$(libz_cc)),$(libz_cc),$(firstword $(shell \
for d in $$(echo "$$LD_LIBRARY_PATH" | tr ':' ' '); do \
f=$$(find "$$d" -maxdepth 1 -name 'libz.so.1' 2>/dev/null | head -1); \
test -n "$$f" && echo "$$f" && break; \
done)))
module:
$(call very-quiet, echo /usr/lib/libz.so.1: $(libz) > usr.manifest)
2 changes: 1 addition & 1 deletion modules/monitoring-agent/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ client::client(int _time_out)
{ }

template<typename Duration>
static void connect_with_timeout(boost::asio::io_service& io_service,
static void connect_with_timeout(boost::asio::io_context& io_service,
boost::asio::ip::tcp::socket& _socket, tcp::endpoint& _endpoint,
boost::system::error_code& ec, Duration duration)
{
Expand Down
2 changes: 1 addition & 1 deletion modules/monitoring-agent/client.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private:
void process_headers();
boost::asio::streambuf response;
unsigned int status_code;
boost::asio::io_service io_service;
boost::asio::io_context io_service;
boost::asio::ip::tcp::socket _socket;
bool done = false;
int time_out;
Expand Down
19 changes: 12 additions & 7 deletions modules/openssl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
SRC = $(shell readlink -f ../..)

module:
$(SRC)/scripts/manifest_from_host.sh -l libssl.so.1.1 > usr.manifest
# From krb5-libs
$(SRC)/scripts/manifest_from_host.sh -l libgssapi_krb5.so.2 >> usr.manifest
# From libselinux
$(SRC)/scripts/manifest_from_host.sh -l libselinux.so.1 >> usr.manifest
# From xz-libs
$(SRC)/scripts/manifest_from_host.sh -l liblzma.so.5 >> usr.manifest
# Support OpenSSL 3.x (libssl.so.3) and legacy 1.1.x (libssl.so.1.1).
# OpenSSL 3.x is the current standard on modern distros and NixOS.
if $(SRC)/scripts/manifest_from_host.sh -l libssl.so.3 > usr.manifest 2>/dev/null && \
grep -q libssl usr.manifest 2>/dev/null; then \
true; \
else \
$(SRC)/scripts/manifest_from_host.sh -l libssl.so.1.1 > usr.manifest; \
fi
# Optional runtime dependencies -- silently ignored if absent on host
$(SRC)/scripts/manifest_from_host.sh -li libgssapi_krb5.so.2 >> usr.manifest
$(SRC)/scripts/manifest_from_host.sh -li libselinux.so.1 >> usr.manifest
$(SRC)/scripts/manifest_from_host.sh -li liblzma.so.5 >> usr.manifest

.PHONY: module

Expand Down
Loading