Skip to content

Commit

Permalink
Improve build instructions, fixing issue #136
Browse files Browse the repository at this point in the history
  • Loading branch information
ned14 committed Sep 5, 2024
1 parent c102bcb commit 2af67da
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 33 deletions.
63 changes: 52 additions & 11 deletions Build.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Build instructions

These compilers and OSs are regularly tested:
These compilers and OSs are regularly tested by CI:

- [GCC](https://gcc.gnu.org/) 9.4 (Linux 5.x x64)
- [Clang](https://clang.llvm.org/) 11 (Linux 5.x x64)
- Xcode 13.2 (macOS 11 x64)
- Visual Studio 2022 (Windows Server 2022 x64).
- [GCC](https://gcc.gnu.org/) on Linux
- [Clang](https://clang.llvm.org/) on Linux
- Xcode on Mac OS
- Visual Studio on Windows

Other compilers, architectures and OSs may work, but are not tested regularly.
You will need a working [Filesystem TS](https://en.cppreference.com/w/cpp/experimental/fs)
Expand Down Expand Up @@ -91,7 +91,7 @@ To build and test on POSIX (`make`, `ninja` etc):
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
cmake --build . --parallel
ctest -R llfio_sl
~~~

Expand All @@ -101,7 +101,7 @@ To build and test on Windows or Mac OS (Visual Studio, XCode etc):
mkdir build
cd build
cmake .. -G<your generator here>
cmake --build . --config Release
cmake --build . --parallel --config Release
ctest -C Release -R llfio_sl
~~~

Expand All @@ -115,7 +115,7 @@ To build and test on POSIX (`make`, `ninja` etc):
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -- _dl
cmake --build . --parallel -- _dl
ctest -R llfio_dl
~~~

Expand All @@ -125,16 +125,57 @@ To build and test on Windows or Mac OS (Visual Studio, XCode etc):
mkdir build
cd build
cmake .. -G<your generator here>
cmake --build . --config Release --target _dl
cmake --build . --parallel --config Release --target _dl
ctest -C Release -R llfio_dl
~~~

## Installing libraries from source

If you add llfio as a subdirectory in cmake (`add_subdirectory()`),
you can link to its exported targets and everything 'just works'. The
dependencies quickcpplib and outcome will be automatically downloaded
into the build directory and used.

If you really want to install llfio into a directory, you can also:

~~~
git config --system core.longpaths true
git clone --recursive https://github.com/ned14/quickcpplib.git
cd quickcpplib
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -- _dl _sl _hl
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build . --parallel
cmake --build . --target install
cd ../..
git clone --recursive https://github.com/ned14/outcome.git
cd outcome
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build . --parallel
cmake --build . --target install
cd ../..
git clone --recursive https://github.com/ned14/llfio.git
cd llfio
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build . --parallel -- _dl _sl _hl
cmake --build . --target install
cd ../..
~~~

If you chose a different `CMAKE_INSTALL_PREFIX` then it will need
to be supplied to the compiler:

~~~
cd example
g++ -std=c++17 -o test map_file.cpp -I/Users/ned/testinstall/inst/include
~~~

The above also works on Microsoft Windows, but paths etc will need to
be adjusted.
76 changes: 56 additions & 20 deletions include/llfio/v2.0/config.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Configures LLFIO
(C) 2015-2020 Niall Douglas <http://www.nedproductions.biz/> (24 commits)
(C) 2015-2024 Niall Douglas <http://www.nedproductions.biz/> (24 commits)
File Created: Dec 2015
Expand All @@ -25,10 +25,10 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef LLFIO_CONFIG_HPP
#define LLFIO_CONFIG_HPP

//#include <iostream>
//#define LLFIO_LOG_TO_OSTREAM std::cerr
//#define LLFIO_LOGGING_LEVEL 1
//#define LLFIO_DISABLE_PATHS_IN_FAILURE_INFO
// #include <iostream>
// #define LLFIO_LOG_TO_OSTREAM std::cerr
// #define LLFIO_LOGGING_LEVEL 1
// #define LLFIO_DISABLE_PATHS_IN_FAILURE_INFO

//! \file config.hpp Configures a compiler environment for LLFIO header and source code

Expand Down Expand Up @@ -85,6 +85,17 @@ Distributed under the Boost Software License, Version 1.0.
#define LLFIO_EXPERIMENTAL_STATUS_CODE 0
#endif

// Exclude deprecated stuff by default
#ifndef LLFIO_EXCLUDE_DYNAMIC_THREAD_POOL_GROUP
#define LLFIO_EXCLUDE_DYNAMIC_THREAD_POOL_GROUP 1
#endif
#ifndef LLFIO_EXCLUDE_NETWORKING
#define LLFIO_EXCLUDE_NETWORKING 1
#endif
#ifndef LLFIO_DISABLE_OPENSSL
#define LLFIO_DISABLE_OPENSSL 1
#endif


#if defined(_WIN32)
#if !defined(_WIN32_WINNT)
Expand All @@ -106,6 +117,18 @@ Distributed under the Boost Software License, Version 1.0.
#include <_mingw.h>
#endif

#ifdef __has_include
#if !__has_include("quickcpplib/cpp_feature.h") && !__has_include("outcome/try.hpp")
#error "Could not find quickcpplib nor outcome. If you installed LLFIO, did you also install quickcpplib and outcome?"
#endif
#if !__has_include("quickcpplib/cpp_feature.h")
#error "Could not find quickcpplib. If you installed LLFIO, did you also install quickcpplib?"
#endif
#if !__has_include("outcome/try.hpp")
#error "Could not find outcome. If you installed LLFIO, did you also install outcome?"
#endif
#endif

#include "quickcpplib/cpp_feature.h"

#ifndef STANDARDESE_IS_IN_THE_HOUSE
Expand Down Expand Up @@ -181,15 +204,15 @@ namespace starting with `v2_` inside the `boost::llfio` namespace.
/*! \brief Expands into the appropriate namespace markup to enter the LLFIO v2 namespace.
\ingroup config
*/
#define LLFIO_V2_NAMESPACE_BEGIN \
namespace llfio_v2_xxx \
#define LLFIO_V2_NAMESPACE_BEGIN \
namespace llfio_v2_xxx \
{
/*! \brief Expands into the appropriate namespace markup to enter the C++ module
exported LLFIO v2 namespace.
\ingroup config
*/
#define LLFIO_V2_NAMESPACE_EXPORT_BEGIN \
export namespace llfio_v2_xxx \
#define LLFIO_V2_NAMESPACE_EXPORT_BEGIN \
export namespace llfio_v2_xxx \
{
/*! \brief Expands into the appropriate namespace markup to exit the LLFIO v2 namespace.
\ingroup config
Expand Down Expand Up @@ -266,7 +289,8 @@ LLFIO_V2_NAMESPACE_END
#endif
#if LLFIO_USING_EXPERIMENTAL_FILESYSTEM && !LLFIO_DISABLE_USING_EXPERIMENTAL_FILESYSTEM_WARNING
#ifdef _MSC_VER
#pragma message("WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO.")
#pragma message( \
"WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO.")
#else
#warning WARNING: LLFIO is using the experimental Filesystem TS instead of the standard Filesystem, there are many corner case surprises in the former! Support for the Experimental Filesystem TS is expected to be deprecated at some point, and C++ 17 shall become the minimum required for LLFIO.
#endif
Expand Down Expand Up @@ -364,7 +388,8 @@ LLFIO_V2_NAMESPACE_END
// Bring in a function_ptr implementation
#include "quickcpplib/function_ptr.hpp"
LLFIO_V2_NAMESPACE_BEGIN
template <class F, size_t callable_storage_bytes = 32 - sizeof(uintptr_t)> using function_ptr = QUICKCPPLIB_NAMESPACE::function_ptr::function_ptr<F, callable_storage_bytes>;
template <class F, size_t callable_storage_bytes = 32 - sizeof(uintptr_t)>
using function_ptr = QUICKCPPLIB_NAMESPACE::function_ptr::function_ptr<F, callable_storage_bytes>;
using QUICKCPPLIB_NAMESPACE::function_ptr::emplace_function_ptr;
using QUICKCPPLIB_NAMESPACE::function_ptr::emplace_function_ptr_nothrow;
using QUICKCPPLIB_NAMESPACE::function_ptr::make_function_ptr;
Expand Down Expand Up @@ -396,7 +421,7 @@ LLFIO_V2_NAMESPACE_END
#include "quickcpplib/spinlock.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using spinlock = QUICKCPPLIB_NAMESPACE::configurable_spinlock::spinlock<uintptr_t>;
using QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard;
using QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard;
LLFIO_V2_NAMESPACE_END
// Bring in a memory resource implementation
#include "quickcpplib/memory_resource.hpp"
Expand All @@ -412,13 +437,22 @@ namespace detail
// Used to cast an unknown input to some unsigned integer
LLFIO_TEMPLATE(class T, class U)
LLFIO_TREQUIRES(LLFIO_TPRED(std::is_unsigned<T>::value && !std::is_same<std::decay_t<U>, std::nullptr_t>::value))
inline T unsigned_integer_cast(U &&v) { return static_cast<T>(v); }
inline T unsigned_integer_cast(U &&v)
{
return static_cast<T>(v);
}
LLFIO_TEMPLATE(class T)
LLFIO_TREQUIRES(LLFIO_TPRED(std::is_unsigned<T>::value))
inline T unsigned_integer_cast(std::nullptr_t /* unused */) { return static_cast<T>(0); }
inline T unsigned_integer_cast(std::nullptr_t /* unused */)
{
return static_cast<T>(0);
}
LLFIO_TEMPLATE(class T, class U)
LLFIO_TREQUIRES(LLFIO_TPRED(std::is_unsigned<T>::value))
inline T unsigned_integer_cast(U *v) { return static_cast<T>(reinterpret_cast<uintptr_t>(v)); }
inline T unsigned_integer_cast(U *v)
{
return static_cast<T>(reinterpret_cast<uintptr_t>(v));
}
} // namespace detail

LLFIO_V2_NAMESPACE_END
Expand All @@ -437,10 +471,10 @@ namespace win
LLFIO_V2_NAMESPACE_END


//#define BOOST_THREAD_VERSION 4
//#define BOOST_THREAD_PROVIDES_VARIADIC_THREAD
//#define BOOST_THREAD_DONT_PROVIDE_FUTURE
//#define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
// #define BOOST_THREAD_VERSION 4
// #define BOOST_THREAD_PROVIDES_VARIADIC_THREAD
// #define BOOST_THREAD_DONT_PROVIDE_FUTURE
// #define BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
#if LLFIO_HEADERS_ONLY == 1 && !defined(LLFIO_SOURCE)
/*! \brief Expands into the appropriate markup to declare an `extern`
function exported from the LLFIO DLL if not building headers only.
Expand Down Expand Up @@ -483,7 +517,9 @@ namespace detail
{
if(sizeof(LLFIO_V2_NAMESPACE::filesystem::path) != sizeof_filesystem_path())
{
fprintf(stderr, "FATAL: sizeof(filesystem::path) = %u differs in the translation unit '%s' to the sizeof(filesystem::path) = %u as when LLFIO was built!\n", (unsigned) sizeof(LLFIO_V2_NAMESPACE::filesystem::path), filepath, (unsigned) sizeof_filesystem_path());
fprintf(stderr,
"FATAL: sizeof(filesystem::path) = %u differs in the translation unit '%s' to the sizeof(filesystem::path) = %u as when LLFIO was built!\n",
(unsigned) sizeof(LLFIO_V2_NAMESPACE::filesystem::path), filepath, (unsigned) sizeof_filesystem_path());
abort();
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/llfio/v2.0/detail/impl/posix/directory_handle.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ http://www.boost.org/LICENSE_1_0.txt)
#include "quickcpplib/valgrind/memcheck.h" // from quickcpplib include directory
#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b) VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE((a), (b))
#else
#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b)
#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b) (0)
#endif

#include <dirent.h> /* Defines DT_* constants */
Expand Down Expand Up @@ -443,7 +443,7 @@ result<directory_handle::buffers_type> directory_handle::read(io_request<buffers
req.buffers._done = true;
return std::move(req.buffers);
}
LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(buffer, bytes); // NOLINT
(void) LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(buffer, bytes); // NOLINT
size_t n = 0;
for(dirent *dent = buffer;; dent = reinterpret_cast<dirent *>(reinterpret_cast<uintptr_t>(dent) + dent->d_reclen))
{
Expand Down

0 comments on commit 2af67da

Please sign in to comment.