Skip to content

Commit fd42f5a

Browse files
authored
Merge pull request #1273 from fwsGonzo/dev
Add support for building with g++
2 parents 11edfff + 3947585 commit fd42f5a

34 files changed

Lines changed: 296 additions & 203 deletions

CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(SCRIPTS ${CMAKE_INSTALL_PREFIX}/includeos/scripts)
1414
if(CMAKE_COMPILER_IS_GNUCC)
1515
# currently gcc is not supported due to problems cross-compiling a unikernel
1616
# (i.e., building a 32bit unikernel (only supported for now) on a 64bit system)
17-
message(FATAL_ERROR "Building IncludeOS with gcc is not currently supported. Please clean-up build directory and configure for clang through CC and CXX environmental variables.")
17+
# message(FATAL_ERROR "Building IncludeOS with gcc is not currently supported. Please clean-up build directory and configure for clang through CC and CXX environmental variables.")
1818
endif(CMAKE_COMPILER_IS_GNUCC)
1919

2020
# create OS version string from git describe (used in CXX flags)
@@ -92,12 +92,19 @@ endif(silent)
9292
# Append optimization level
9393
set(CAPABS "${CAPABS} ${OPTIMIZE}")
9494

95-
# these kinda work with llvm
96-
set(CMAKE_CXX_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
97-
set(CMAKE_C_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -DOS_VERSION=\"\"${OS_VERSION}\"\"")
95+
if (CMAKE_COMPILER_IS_GNUCC)
96+
# gcc/g++ settings
97+
set(CMAKE_CXX_FLAGS "-m32 -MMD ${CAPABS} ${WARNS} -Wno-frame-address -nostdlib -c -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
98+
set(CMAKE_C_FLAGS "-m32 -MMD ${CAPABS} ${WARNS} -nostdlib -c -DOS_VERSION=\"\"${OS_VERSION}\"\"")
99+
else()
100+
# these kinda work with llvm
101+
set(CMAKE_CXX_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION=\\\"${OS_VERSION}\\\"")
102+
set(CMAKE_C_FLAGS "-target i686 -MMD ${CAPABS} ${WARNS} -nostdlib -nostdlibinc -c -m32 -DOS_VERSION=\"\"${OS_VERSION}\"\"")
103+
endif()
98104

99105
# either download or cross-compile needed libraries
100-
option(from_bundle "Download and use pre-compiled libraries for cross-comilation" ON)
106+
#option(from_bundle "Download and use pre-compiled libraries for cross-comilation" ON)
107+
set(BUNDLE_LOC "" CACHE STRING "Local path of bundle with pre-compile libraries")
101108
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cross_compiled_libraries.txt)
102109

103110
# Botan Crypto & TLS

api/fs/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ namespace fs {
188188
using on_init_func = delegate<void(error_t, File_system&)>;
189189
using on_ls_func = delegate<void(error_t, dirvec_t)>;
190190
using on_read_func = delegate<void(error_t, buffer_t, uint64_t)>;
191-
using on_stat_func = delegate<void(error_t, const Dirent&)>;
191+
using on_stat_func = delegate<void(error_t, Dirent)>;
192192

193193

194194
struct List

api/net/inet.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace net {
179179
///
180180

181181
/** Get Maximum Transmission Unit **/
182-
virtual constexpr uint16_t MTU() const = 0;
182+
virtual uint16_t MTU() const = 0;
183183

184184
/** Provision empty anonymous packet **/
185185
virtual Packet_ptr create_packet() = 0;

api/net/ip4/ip4.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace net {
5757
/*
5858
Maximum Datagram Data Size
5959
*/
60-
constexpr uint16_t MDDS() const
60+
uint16_t MDDS() const
6161
{ return stack_.MTU() - sizeof(ip4::Header); }
6262

6363
/** Upstream: Input from link layer */

api/net/ip4/udp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ namespace net {
133133
// create and transmit @num packets from sendq
134134
void process_sendq(size_t num);
135135

136-
inline constexpr uint16_t max_datagram_size() noexcept {
136+
uint16_t max_datagram_size() noexcept {
137137
return stack().ip_obj().MDDS() - sizeof(header);
138138
}
139139

api/net/tcp/connection.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ class Connection : public std::enable_shared_from_this<Connection> {
498498
*
499499
* @return True if able to send, False otherwise.
500500
*/
501-
constexpr bool can_send() const noexcept
501+
bool can_send() const noexcept
502502
{ return (usable_window() >= SMSS()) and writeq.has_remaining_requests(); }
503503

504504
/**
@@ -756,6 +756,8 @@ class Connection : public std::enable_shared_from_this<Connection> {
756756
recover = ISS; // [RFC 6582]
757757
}
758758

759+
uint32_t get_ts_recent() const noexcept { return TS_recent; }
760+
759761
bool slow_start() const noexcept
760762
{ return cwnd < ssthresh; }
761763

@@ -1115,7 +1117,7 @@ class Connection : public std::enable_shared_from_this<Connection> {
11151117
*
11161118
* @return True if able to send one, False otherwise.
11171119
*/
1118-
constexpr bool can_send_one() const
1120+
bool can_send_one() const
11191121
{ return send_window() >= SMSS() and writeq.has_remaining_requests(); }
11201122

11211123
/**

api/net/tcp/tcp.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ namespace net {
354354
*
355355
* @return The window size
356356
*/
357-
constexpr uint32_t window_size() const
357+
uint32_t window_size() const
358358
{ return win_size_; }
359359

360360
/**
@@ -371,7 +371,7 @@ namespace net {
371371
*
372372
* @return The wscale factor
373373
*/
374-
constexpr uint8_t wscale() const
374+
uint8_t wscale() const
375375
{ return wscale_; }
376376

377377
/**
@@ -380,7 +380,7 @@ namespace net {
380380
*
381381
* @return Whether wscale is being used
382382
*/
383-
constexpr bool uses_wscale() const
383+
bool uses_wscale() const
384384
{ return wscale_ > 0; }
385385

386386
/**
@@ -396,7 +396,7 @@ namespace net {
396396
*
397397
* @return Whether the TCP instance is using Timestamp Options or not
398398
*/
399-
constexpr bool uses_timestamps() const
399+
bool uses_timestamps() const
400400
{ return timestamps_; }
401401

402402
/**
@@ -428,7 +428,7 @@ namespace net {
428428
*
429429
* @return The limit
430430
*/
431-
constexpr uint16_t max_syn_backlog() const
431+
uint16_t max_syn_backlog() const
432432
{ return max_syn_backlog_; }
433433

434434
/**
@@ -438,7 +438,7 @@ namespace net {
438438
*
439439
* @return The MSS
440440
*/
441-
constexpr uint16_t MSS() const
441+
uint16_t MSS() const
442442
{ return network().MDDS() - sizeof(tcp::Header); }
443443

444444
/**

api/net/tls/server.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Server : public Botan::TLS::Callbacks, public tcp::Stream
3838
Server(Connection_ptr remote,
3939
Botan::RandomNumberGenerator& rng,
4040
Botan::Credentials_Manager& credman)
41-
: tcp::Stream({remote}),
41+
: tcp::Stream{remote},
4242
m_creds(credman),
4343
m_session_manager(),
4444
m_tls(*this, m_session_manager, m_creds, m_policy, rng)

api/smp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ public:
133133
};
134134

135135
// access a std::array of structs indexed by current CPU id
136+
#ifdef INCLUDEOS_SINGLE_THREADED
137+
#define PER_CPU(x) (per_cpu_help<decltype(x)::value_type, 1>(x))
138+
#else
136139
#define PER_CPU(x) (per_cpu_help<decltype(x)::value_type, x.size()>(x))
140+
#endif
137141

138142
#ifndef ARCH_X86
139143
typedef int spinlock_t;
@@ -142,4 +146,3 @@ inline void unlock(spinlock_t&) {}
142146
#endif
143147

144148
#endif
145-

api/util/chunk.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Chunk {
9797
*
9898
* @return The byte at index
9999
*/
100-
constexpr byte_t& operator[](index_type idx) const noexcept
100+
byte_t& operator[](index_type idx) const noexcept
101101
{ return data()[idx]; }
102102

103103
/**
@@ -193,14 +193,14 @@ class Chunk {
193193

194194
iterator& operator=(const iterator&) noexcept = default;
195195

196-
constexpr reference operator*() const
196+
reference operator*() const
197197
{
198198
Expects(chunk_ && *chunk_);
199199

200200
return (*chunk_)[index_];
201201
}
202202

203-
constexpr pointer operator->() const
203+
pointer operator->() const
204204
{
205205
Expects(chunk_ && *chunk_);
206206

0 commit comments

Comments
 (0)