From e51b855f2bfddd7a25b320b01fc44d78642af29e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 26 May 2022 12:28:28 -0700 Subject: [PATCH] ircd: Various symbol surface reductions and sorting. --- include/ircd/allocator.h | 16 ++++++++-------- include/ircd/cl/init.h | 3 ++- include/ircd/client.h | 3 ++- include/ircd/ctx/continuation.h | 3 ++- include/ircd/ctx/ole.h | 3 ++- include/ircd/db/db.h | 3 ++- include/ircd/exception.h | 6 +++--- include/ircd/fs/aio.h | 3 ++- include/ircd/fs/fs.h | 3 ++- include/ircd/fs/iou.h | 3 ++- include/ircd/magic.h | 3 ++- include/ircd/magick.h | 13 +++++++------ include/ircd/net/net.h | 3 ++- include/ircd/net/socket.h | 2 +- include/ircd/openssl.h | 3 ++- include/ircd/server/server.h | 3 ++- ircd/Makefile.am | 4 ++++ ircd/ctx.cc | 25 +++++++++++++++++-------- ircd/fs_aio.h | 23 ++++++++++++++--------- ircd/fs_iou.h | 8 ++++---- 20 files changed, 82 insertions(+), 51 deletions(-) diff --git a/include/ircd/allocator.h b/include/ircd/allocator.h index 4dfa571a2..39c9162bd 100644 --- a/include/ircd/allocator.h +++ b/include/ircd/allocator.h @@ -275,14 +275,14 @@ struct ircd::allocator::callback::allocator }; template -typename ircd::allocator::callback::allocator +inline typename ircd::allocator::callback::allocator ircd::allocator::callback::operator()() { return ircd::allocator::callback::allocator(*this); } template -ircd::allocator::callback::operator +inline ircd::allocator::callback::operator allocator() { return ircd::allocator::callback::allocator(*this); @@ -423,7 +423,7 @@ struct ircd::allocator::fixed::allocator template -typename ircd::allocator::fixed::allocator +inline typename ircd::allocator::fixed::allocator ircd::allocator::fixed::operator()() { return ircd::allocator::fixed::allocator(*this); @@ -431,7 +431,7 @@ ircd::allocator::fixed::operator()() template -ircd::allocator::fixed::operator +inline ircd::allocator::fixed::operator allocator() { return ircd::allocator::fixed::allocator(*this); @@ -541,14 +541,14 @@ struct ircd::allocator::dynamic::allocator }; template -typename ircd::allocator::dynamic::allocator +inline typename ircd::allocator::dynamic::allocator ircd::allocator::dynamic::operator()() { return ircd::allocator::dynamic::allocator(*this); } template -ircd::allocator::dynamic::operator +inline ircd::allocator::dynamic::operator allocator() { return ircd::allocator::dynamic::allocator(*this); @@ -771,7 +771,7 @@ struct ircd::allocator::twolevel::allocator template -typename ircd::allocator::twolevel::allocator +inline typename ircd::allocator::twolevel::allocator ircd::allocator::twolevel::operator()() { return ircd::allocator::twolevel::allocator(*this); @@ -779,7 +779,7 @@ ircd::allocator::twolevel::operator()() template -ircd::allocator::twolevel::operator +inline ircd::allocator::twolevel::operator allocator() { return ircd::allocator::twolevel::allocator(*this); diff --git a/include/ircd/cl/init.h b/include/ircd/cl/init.h index 6c69edcba..aaee87884 100644 --- a/include/ircd/cl/init.h +++ b/include/ircd/cl/init.h @@ -24,7 +24,8 @@ namespace ircd::cl void log_platform_info(); } -class ircd::cl::init +class [[gnu::visibility("hidden")]] +ircd::cl::init { size_t init_platforms(); size_t init_devices(); diff --git a/include/ircd/client.h b/include/ircd/client.h index 08284d766..9a931225b 100644 --- a/include/ircd/client.h +++ b/include/ircd/client.h @@ -116,7 +116,8 @@ struct ircd::client::settings static ircd::conf::item max_client_per_peer; }; -struct ircd::client::init +struct [[gnu::visibility("hidden")]] +ircd::client::init { init(); ~init() noexcept; diff --git a/include/ircd/ctx/continuation.h b/include/ircd/ctx/continuation.h index 980d037bc..9480588cd 100644 --- a/include/ircd/ctx/continuation.h +++ b/include/ircd/ctx/continuation.h @@ -46,7 +46,8 @@ namespace ircd /// own after receiving an interruption without help from this action. Common /// use for this is with yields to asio. /// -struct ircd::ctx::continuation +struct [[gnu::visibility("hidden")]] +ircd::ctx::continuation { static const predicate asio_predicate; static const predicate true_predicate; diff --git a/include/ircd/ctx/ole.h b/include/ircd/ctx/ole.h index 6a0f0db0f..6279f9413 100644 --- a/include/ircd/ctx/ole.h +++ b/include/ircd/ctx/ole.h @@ -49,7 +49,8 @@ struct ircd::ctx::ole::opts int8_t prio {0}; }; -struct ircd::ctx::ole::init +struct [[gnu::visibility("hidden")]] +ircd::ctx::ole::init { init(); ~init() noexcept; diff --git a/include/ircd/db/db.h b/include/ircd/db/db.h index 91ac75eba..794ef6070 100644 --- a/include/ircd/db/db.h +++ b/include/ircd/db/db.h @@ -83,7 +83,8 @@ namespace ircd } /// Database subsystem initialization and destruction -struct ircd::db::init +struct [[gnu::visibility("hidden")]] +ircd::db::init { static const std::string direct_io_test_file_path; diff --git a/include/ircd/exception.h b/include/ircd/exception.h index 18edf82bc..9f0a010e2 100644 --- a/include/ircd/exception.h +++ b/include/ircd/exception.h @@ -220,7 +220,7 @@ namespace ircd template -std::exception_ptr +inline std::exception_ptr ircd::make_exception_ptr(args&&... a) try { @@ -232,14 +232,14 @@ catch(const E &) }; template -void +inline void ircd::throw_system_error(args&&... a) { throw make_system_error(std::forward(a)...); } template -std::exception_ptr +inline std::exception_ptr ircd::make_system_eptr(args&&... a) { return std::make_exception_ptr(make_system_error(std::forward(a)...)); diff --git a/include/ircd/fs/aio.h b/include/ircd/fs/aio.h index e0bc6c44e..571e9245b 100644 --- a/include/ircd/fs/aio.h +++ b/include/ircd/fs/aio.h @@ -84,7 +84,8 @@ struct ircd::fs::aio::stats stats(); }; -struct ircd::fs::aio::init +struct [[gnu::visibility("hidden")]] +ircd::fs::aio::init { init(); ~init() noexcept; diff --git a/include/ircd/fs/fs.h b/include/ircd/fs/fs.h index 6183c2523..e6512b93c 100644 --- a/include/ircd/fs/fs.h +++ b/include/ircd/fs/fs.h @@ -78,7 +78,8 @@ namespace ircd::fs } /// Filesystem interface init / fini held by ircd::main(). -struct ircd::fs::init +struct [[gnu::visibility("hidden")]] +ircd::fs::init { iou::init _iou_; aio::init _aio_; diff --git a/include/ircd/fs/iou.h b/include/ircd/fs/iou.h index f8216d2ed..0e771139e 100644 --- a/include/ircd/fs/iou.h +++ b/include/ircd/fs/iou.h @@ -89,7 +89,8 @@ enum ircd::fs::iou::state /// Internal use; this is simply declared here for when internal headers are /// not available for this build so a weak no-op definition can be defined. -struct ircd::fs::iou::init +struct [[gnu::visibility("hidden")]] +ircd::fs::iou::init { init(); ~init() noexcept; diff --git a/include/ircd/magic.h b/include/ircd/magic.h index ce7a20234..7420b5f30 100644 --- a/include/ircd/magic.h +++ b/include/ircd/magic.h @@ -28,7 +28,8 @@ namespace ircd::magic extern const info::versions version_api, version_abi; } -struct ircd::magic::init +struct [[gnu::visibility("hidden")]] +ircd::magic::init { init(); ~init() noexcept; diff --git a/include/ircd/magick.h b/include/ircd/magick.h index 61ee8c296..b2dbeaa1d 100644 --- a/include/ircd/magick.h +++ b/include/ircd/magick.h @@ -27,12 +27,6 @@ namespace ircd::magick extern const info::versions version_api, version_abi; } -struct ircd::magick::init -{ - init(); - ~init() noexcept; -}; - /// Composite thumbnailer to resize close to the requested dimension but /// preserving original aspect ratio; then crop to requested dimension. struct ircd::magick::thumbcrop @@ -111,6 +105,13 @@ struct ircd::magick::job std::exception_ptr eptr; // apropos exception reference }; +struct [[gnu::visibility("hidden")]] +ircd::magick::init +{ + init(); + ~init() noexcept; +}; + // inline stubs when magick disabled/unavailable. #if !IRCD_USE_MAGICK diff --git a/include/ircd/net/net.h b/include/ircd/net/net.h index b7e0df52b..9f6e9a4d0 100644 --- a/include/ircd/net/net.h +++ b/include/ircd/net/net.h @@ -73,7 +73,8 @@ namespace ircd using net::socket; } -struct ircd::net::init +struct [[gnu::visibility("hidden")]] +ircd::net::init { init(); ~init() noexcept; diff --git a/include/ircd/net/socket.h b/include/ircd/net/socket.h index f0c1512ca..cf1769b5b 100644 --- a/include/ircd/net/socket.h +++ b/include/ircd/net/socket.h @@ -129,7 +129,7 @@ struct ircd::net::socket }; template -auto +inline auto ircd::net::socket::operator()(args&&... a) { return this->wait(std::forward(a)...); diff --git a/include/ircd/openssl.h b/include/ircd/openssl.h index c4699c536..1ecdf2680 100644 --- a/include/ircd/openssl.h +++ b/include/ircd/openssl.h @@ -212,7 +212,8 @@ class ircd::openssl::bignum ~bignum() noexcept; }; -struct ircd::openssl::init +struct [[gnu::visibility("hidden")]] +ircd::openssl::init { init(); ~init() noexcept; diff --git a/include/ircd/server/server.h b/include/ircd/server/server.h index 7c8f1612c..cedec24cf 100644 --- a/include/ircd/server/server.h +++ b/include/ircd/server/server.h @@ -63,7 +63,8 @@ namespace ircd::server /// Subsystem initialization / destruction from ircd::main /// -struct ircd::server::init +struct [[gnu::visibility("hidden")]] +ircd::server::init { // manual control panel static void interrupt(); diff --git a/ircd/Makefile.am b/ircd/Makefile.am index b45db5bd1..6c4100cab 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -24,6 +24,10 @@ AM_CPPFLAGS = \ AM_LDFLAGS = \ -version-info 3:2:0 \ -Wl,--no-undefined-version \ + -Wl,--icf=all \ + -Wl,--no-text-reorder \ + -Wl,--sort-section=name \ + -Wl,--sort-common=descending \ -Wl,--weak-unresolved-symbols \ -Wl,--unresolved-symbols=ignore-in-shared-libs \ -Wl,--wrap=pthread_create \ diff --git a/ircd/ctx.cc b/ircd/ctx.cc index a25a330e7..8f10cf8a6 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -64,7 +64,7 @@ ircd::ctx::ctx::ios_handler }; /// Points to the next context to spawn (internal use) -[[gnu::visibility("internal")]] +[[gnu::visibility("hidden")]] decltype(ircd::ctx::ctx::spawning) ircd::ctx::ctx::spawning; @@ -74,6 +74,7 @@ decltype(ircd::ctx::ctx::adjoindre) ircd::ctx::ctx::adjoindre; /// Internal context struct ctor +[[gnu::visibility("hidden")]] ircd::ctx::ctx::ctx(const string_view &name, const ircd::ctx::stack &stack, const context::flags &flags) @@ -93,6 +94,7 @@ ircd::ctx::ctx::ctx(const string_view &name, strlcpy(this->name, name); } +[[gnu::visibility("hidden")]] ircd::ctx::ctx::~ctx() noexcept { @@ -100,6 +102,7 @@ noexcept } /// Internal wrapper for asio::spawn; never call directly. +[[gnu::visibility("hidden")]] void IRCD_CTX_STACK_PROTECT ircd::ctx::ctx::spawn(context::function func) @@ -160,6 +163,7 @@ ircd::ctx::ctx::spawn(context::function func) /// /// This function is the first thing executed on the new context's stack /// and calls the user's function. +[[gnu::visibility("hidden")]] void IRCD_CTX_STACK_PROTECT ircd::ctx::ctx::operator()(boost::asio::yield_context yc, @@ -232,6 +236,7 @@ catch(const std::exception &e) /// /// This currently doesn't work yet because the suspension state of this /// context has to be ready to be jumped to and that isn't implemented yet. +[[gnu::visibility("hidden")]] void IRCD_CTX_STACK_PROTECT ircd::ctx::ctx::jump() @@ -265,7 +270,7 @@ ircd::ctx::ctx::jump() /// considered handled an another attempt to `wait()` can be made. Returns true /// if the context suspended and was notified. When a context wakes up the /// note counter is reset. -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] bool IRCD_CTX_STACK_PROTECT ircd::ctx::ctx::wait() @@ -320,6 +325,7 @@ ircd::ctx::ctx::wait() /// /// Returns true if this note was the first note received by this context /// while it's been suspended or false if it's already been notified. +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::note() noexcept @@ -334,6 +340,7 @@ noexcept } /// Wakes a context without a note (internal) +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::wake() noexcept try @@ -370,7 +377,7 @@ catch(const std::exception &e) /// Throws if this context has been flagged for interruption and clears /// the flag. -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] void ircd::ctx::ctx::interruption_point() { @@ -390,7 +397,7 @@ ircd::ctx::ctx::interruption_point() /// Returns true if this context has been flagged for termination. Does not /// clear the flag. Sets the NOINTERRUPT flag so the context cannot be further // interrupted which simplifies the termination process. -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::termination_point(std::nothrow_t) noexcept @@ -407,7 +414,7 @@ noexcept /// Returns true if this context has been flagged for interruption and /// clears the flag. -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::interruption_point(std::nothrow_t) noexcept @@ -424,7 +431,7 @@ noexcept /// True if this context has been flagged for interruption or termination /// and interrupts are not blocked. -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::interruption() const noexcept @@ -447,7 +454,7 @@ const noexcept return true; } -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::started() const noexcept @@ -455,7 +462,7 @@ const noexcept return stack.base != 0; } -[[gnu::hot]] +[[gnu::visibility("hidden"), gnu::hot]] bool ircd::ctx::ctx::finished() const noexcept @@ -825,6 +832,7 @@ ircd::ctx::this_ctx::wait() c.wait(); // now you're yielding with portals } +[[gnu::hot, gnu::noinline]] size_t ircd::ctx::this_ctx::stack_at_here() { @@ -834,6 +842,7 @@ ircd::ctx::this_ctx::stack_at_here() /// Throws interrupted if the currently running context was interrupted /// and clears the interrupt flag. +[[gnu::hot]] void ircd::ctx::this_ctx::interruption_point() { diff --git a/ircd/fs_aio.h b/ircd/fs_aio.h index 59fc19cb9..84704451b 100644 --- a/ircd/fs_aio.h +++ b/ircd/fs_aio.h @@ -22,20 +22,20 @@ /// The resolution is very low at 10ms but it is not expensive to use. //#define RB_DEBUG_FS_AIO_SUBMIT_BLOCKING +#pragma GCC visibility push(hidden) namespace ircd::fs::aio { - struct system; - struct request; - size_t write(const fd &, const const_iovec_view &, const write_opts &); size_t read(const vector_view &); size_t read(const fd &, const const_iovec_view &, const read_opts &); size_t fsync(const fd &, const sync_opts &); } +#pragma GCC visibility pop /// AIO context instance from the system. Right now this is a singleton with /// an extern instance pointer at fs::aio::context maintained by fs::aio::init. -struct ircd::fs::aio::system +struct [[gnu::visibility("hidden")]] +ircd::fs::aio::system { struct aio_context; @@ -100,7 +100,8 @@ struct ircd::fs::aio::system ~system() noexcept; }; -struct ircd::fs::aio::system::aio_context +struct [[gnu::visibility("internal")]] +ircd::fs::aio::system::aio_context { static constexpr uint MAGIC {0xA10A10A1}; @@ -117,7 +118,8 @@ struct ircd::fs::aio::system::aio_context // 128 bytes + ring size /// Generic request control block. -struct ircd::fs::aio::request +struct [[gnu::visibility("hidden")]] +ircd::fs::aio::request :iocb { struct read; @@ -152,7 +154,8 @@ struct ircd::fs::aio::request }; /// Read request control block -struct ircd::fs::aio::request::read +struct [[gnu::visibility("hidden")]] +ircd::fs::aio::request::read :request { read(ctx::dock &, const int &fd, const read_opts &, const const_iovec_view &); @@ -160,7 +163,8 @@ struct ircd::fs::aio::request::read }; /// Write request control block -struct ircd::fs::aio::request::write +struct [[gnu::visibility("hidden")]] +ircd::fs::aio::request::write :request { write(ctx::dock &, const int &fd, const write_opts &, const const_iovec_view &); @@ -168,7 +172,8 @@ struct ircd::fs::aio::request::write }; /// fsync request control block -struct ircd::fs::aio::request::fsync +struct [[gnu::visibility("hidden")]] +ircd::fs::aio::request::fsync :request { fsync(ctx::dock &, const int &fd, const sync_opts &); diff --git a/ircd/fs_iou.h b/ircd/fs_iou.h index 28964a672..cc5c0d12e 100644 --- a/ircd/fs_iou.h +++ b/ircd/fs_iou.h @@ -12,17 +12,17 @@ #define HAVE_FS_IOU_H #include +#pragma GCC visibility push(hidden) namespace ircd::fs::iou { - struct system; - struct request; - size_t write(const fd &, const const_iovec_view &, const write_opts &); size_t read(const fd &, const const_iovec_view &, const read_opts &); void fsync(const fd &, const sync_opts &); } +#pragma GCC visibility pop -struct ircd::fs::iou::system +struct [[gnu::visibility("hidden")]] +ircd::fs::iou::system { ctx::dock dock;