summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
AgeCommit message (Collapse)Author
2022-01-04Meta: Remove clang warnings with no violationsAndrew Kaster
At some point we probably needed these, but no code complains about them with the current state of the codebase.
2022-01-04SystemMonitor: Remove unused functions and enable warning globallyAndrew Kaster
These two helpers were the only unused functions clang could detect in the entire codebase. Now that's commitment to no dead code :^)
2022-01-04Userland: Resolve unused-but-set-varaible warningsAndrew Kaster
These are almost always bugs, so enable globally. Remove unused counter variables in SystemMonitor and disk_benchmark.
2022-01-04Userland: Resolve tautological-constant-out-of-range-compare warningsAndrew Kaster
Stop comparing platform-specific sized integer types to max() values of other interger types. Enable the warning everywhere.
2022-01-04Userland: Locally suppress -Wc99-designator and re-enable globallyAndrew Kaster
There's only two places where we're using the C99 feature of array designated initalizers. This feature seemingly wasn't included with C++20 designated initalizers for classes and structs. The only two places we were using this feature are suitably old and isolated that it makes sense to just suppress the warning at the usage sites while discouraging future array designated intializers in new code.
2022-01-04Userland: Resolve -Woverloaded-virtual in LibGUI and SoundPlayerAndrew Kaster
Enable the warning project-wide. It catches when a non-virtual method creates an overload set with a virtual method. This might cause surprising overload resolution depending on how the method is invoked.
2022-01-04Meta: Enable -Wexpansion-to-defined warning for ClangAndrew Kaster
The Clang implementation of this warning protects against some undefined pre-processor behavior while ignoring function-like macros. The gcc implementation also warns on function-like macros, and is therefore noisy.
2022-01-04Meta: Re-enable toolchain version checksAndrew Kaster
These were removed in the Superbuild conversion. Re-add the checks that make sure that if there's a toolchain update, developers re-build their toolchain.
2021-12-29Meta: Use portable gzip option for extracting PCI and USB ID filestuftedocelot
gzip -c is supported in both Linux and BSD flavors of gzip. The -o flag was introduced in a previous commit which is present in OpenBSD, but not other flavors of Linux. -c will write to stdout which is redirected to the target files. As a side benefit, we no longer need to copy files anywhere
2021-12-29Build: Remove gzip -k usage in PCI/USB ID files and crypt for OpenBSDtuftedocelot
OpenBSD gzip does not have the -k flag to keep the original after extraction. Work around this by copying the original gzip to the dest and then extracting. A bit of a hack, but only needs to be done for the first-time or rebuilds OpenBSD provides crypt in libc, not libcrypt. Adjust if/else to check for either and proceed accordingly Remove outdated OpenBSD checks when building the toolchain
2021-12-11Meta: Move compiler-specific warnings into the appropriate if clauseDaniel Bertalan
2021-12-11Everywhere: Fix -Winconsistent-missing-override warnings from ClangDaniel Bertalan
This option is already enabled when building Lagom, so let's enable it for the main build too. We will no longer be surprised by Lagom Clang CI builds failing while everything compiles locally. Furthermore, the stronger `-Wsuggest-override` warning is enabled in this commit, which enforces the use of the `override` keyword in all classes, not just those which already have some methods marked as `override`. This works with both GCC and Clang.
2021-10-20HeaderCheck: It checks some of your headersBen Wiederhake
2021-10-17Toolchain+Meta: Update LLVM version to 13.0.0Daniel Bertalan
This commit updates the Clang toolchain's version to 13.0.0, which comes with better C++20 support and improved handling of new features by clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our Clang binaries will only be 2-4% slower than if we dynamically linked them, but we save hundreds of megabytes of disk space. The `BuildClang.sh` script has been reworked to build the entire toolchain in just three steps: one for the compiler, one for GNU binutils, and one for the runtime libraries. This reduces the complexity of the build script, and will allow us to modify the CI configuration to only rebuild the libraries when our libc headers change. Most of the compile flags have been moved out to a separate CMake cache file, similarly to how the Android and Fuchsia toolchains are implemented within the LLVM repo. This provides a nicer interface than the heaps of command-line arguments. We no longer build separate toolchains for each architecture, as the same Clang binary can compile code for multiple targets. The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in this commit. Clang happily accepts an `i686-pc-serenity` target triple, which matches what our GCC toolchain accepts.
2021-10-10Meta: Re-enable warnings for deprecated copiesBen Wiederhake
This used to supress two true-positives, and zero false-positives. That's good enough in my book to warrant re-activation.
2021-09-15Meta: Switch to a SuperBuild that splits host and target buildsAndrew Kaster
Replace the old logic where we would start with a host build, and swap all the CMake compiler and target variables underneath it to trick CMake into building for Serenity after we configured and built the Lagom code generators. The SuperBuild creates two ExternalProjects, one for Lagom and one for Serenity. The Serenity project depends on the install stage for the Lagom build. The SuperBuild also generates a CMakeToolchain file for the Serenity build to use that replaces the old toolchain file that was only used for Ports. To ensure that code generators are rebuilt when core libraries such as AK and LibCore are modified, developers will need to direct their manual `ninja` invocations to the SuperBuild's binary directory instead of the Serenity binary directory. This commit includes warning coalescing and option style cleanup for the affected CMakeLists in the Kernel, top level, and runtime support libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be confused by a host clang compiler.
2021-09-15Meta: Move all options to targetname_options.cmake filesAndrew Kaster
This common strategy of having a serenity_option() macro defined in either the Lagom or top level CMakeLists.txt allows us to do two things: First, we can more clearly see which options are Serenity-specific, Lagom-specific, or common between the target and host builds. Second, it enables the upcoming SuperBuild changes to set() the options in the SuperBuild's CMake cache and forward each target's options to the corresponding ExternalProject.
2021-09-15Meta: Add Meta/CMake to the CMAKE_MODULE_PATH for Serenity and LagomAndrew Kaster
This makes it so we don't need to specify the full path to all the helper scripts we include() from different places in the codebase and feels a lot cleaner.
2021-09-15Meta: Use Lagom:: namespaced names for code generatorsAndrew Kaster
This will be required when we switch to a SuperBuild that has Lagom as a configure time dependency, but is a distinct enough change to be separate.
2021-09-09Build: Add -fno-delete-null-pointer-checksAndreas Kling
This prevents GCC and Clang from deleting null pointer checks for optimization purposes. I think we're strictly better off crashing in those cases instead of the compiler hiding errors from us.
2021-08-31Build: Pass "-z separate-code" to linkerAndreas Kling
This tells the linker to not combine read-only data and executable code, instead favoring multiple PT_LOAD headers with more precise permissions. This greatly reduces the amount of executable pages in all our programs and libraries. /usr/lib/libjs.so before: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x00000000 0x00000000 0x2fc77c 0x2fc77c R E 0x1000 LOAD 0x2fc900 0x002fd900 0x002fd900 0x0c708 0x0dd1c RW 0x1000 /usr/lib/libjs.so after: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x000000 0x00000000 0x00000000 0x80e60 0x80e60 R 0x1000 LOAD 0x081000 0x00081000 0x00081000 0x25f6c9 0x25f6c9 R E 0x1000 LOAD 0x2e1000 0x002e1000 0x002e1000 0x1c27c 0x1c27c R 0x1000 LOAD 0x2fd900 0x002fe900 0x002fe900 0x0c708 0x0dd1c RW 0x1000 As you can see, we go from 0x2fc77c bytes of executable memory down to 0x25f6c9 (a ~20% reduction!) The memory that was previous executable is now simply read-only instead. :^)
2021-08-31Meta: Require unzip and tar explicitly in CMakeListsAndrew Kaster
This should help stem the tide of people hopping in the build problems channel on discord because they don't have unzip installed.
2021-08-30CMake: Add custom target to build only the generated sourcesBrian Gianforcaro
This is needed so all headers and files exist on disk, so that the sonar cloud analyzer can find them when executing the compilation commands contained in compile_commands.json, without actually building. Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2021-08-28CMake: Don't build Userland and Tests in aarch64 builds for nowNico Weber
2021-08-28CMake: Let `Meta/serenity.sh run aarch64` make it past cmakeNico Weber
This adds just enough scaffolding to make cmake succeed. The build falls over immediately.
2021-08-28Meta: Remove write-only-on-difference scriptAndrew Kaster
It's now been replaced with "${CMAKE_PROGRAM}" -E copy_if_different in all previous usage locations.
2021-08-28Everywhere: Move all host tools into the Lagom/Tools subdirectoryAndrew Kaster
This allows us to remove all the add_subdirectory calls from the top level CMakeLists.txt that referred to targets linking LagomCore. Segregating the host tools and Serenity targets helps us get to a place where the main Serenity build can simply use a CMake toolchain file rather than swapping all the compiler/sysroot variables after building host libraries and tools.
2021-08-28Meta: Prefer SerenityOS_SOURCE_DIR to CMAKE_SOURCE_DIRAndrew Kaster
By using SerenityOS_SOURCE_DIR we can make custom targets and commands agnostic to the actual location of the root CMakeLists directory. All we care about is the root of the SerenityOS project.
2021-08-18Meta+LibC: Don't allow text relocations in SerenityOS librariesDaniel Bertalan
The `-z,text` linker flag causes the linker to reject shared libraries and PIE executables that have textrels. Our code mostly did not use these except in one place in LibC, which is changed in this commit. This makes GNU ld match LLD's behavior, which has this option enabled by default. TEXTRELs pose a security risk, as performing these relocations require executable pages to be written to by the dynamic linker. This can significantly weaken W^X hardening mitigations. Note that after this change, TEXTRELs can still be used in ports, as the dynamic loader code is not changed. There are also uses of it in the kernel, removing which are outside the scope of this PR. To allow those, `-z,notext` is added.
2021-08-12Meta: Enable `nonnull-compare` warningsDaniel Bertalan
Previously, this was disabled because GCC flagged seemingly correct and well-defined code. This was however not the case because GCC implicitly marked some pointers non-null, even if we wanted to handle them ourselves, and deleted null checks on them. By re-introducing this warning, we will know if the compiler tries to discard our code again.
2021-08-08Meta: Add Clang support to the CMake build scriptsDaniel Bertalan
2021-08-08Build: Add -fsized-deallocation to global CXXFLAGSAndreas Kling
This is enabled by default for GCC (>=C++14) but apparently not for Clang, which has been causing CLion to get confused about kernel code.
2021-07-29Kernel: Use our toolchain's c++filt tool for the kernel mapGunnar Beutner
The host's version of c++filt might not work on some operating systems, e.g. macOS.
2021-07-28Toolchain: Update GCC to version 11.2.0Gunnar Beutner
2021-07-26Meta: Add LibUnicode (and its tests) to LagomTimothy Flynn
This is primarily to allow using LibUnicode within LibJS and its REPL. Note: this seems to be the first time that a Lagom dependency requires generated source files. For this to work, some of Lagom's CMakeLists.txt commands needed to be re-organized to include the CMake files that fetch and parse UnicodeData.txt. The paths required to invoke the generator also differ depending on what is currently building (SerenityOS vs. Lagom as part of the Serenity build vs. a standalone Lagom build).
2021-07-26LibUnicode: Introduce a Unicode library for interacting with UCD filesTimothy Flynn
The Unicode standard publishes the Unicode Character Database (UCD) with information about every code point, such as each code point's upper case mapping. LibUnicode exists to download and parse UCD files at build time and to provide accessors to that data. As a start, LibUnicode includes upper- and lower-case code point converters.
2021-07-26Kernel: Add option to build with coverage instrumentation and KCOVPatrick Meyer
GCC and Clang allow us to inject a call to a function named __sanitizer_cov_trace_pc on every edge. This function has to be defined by us. By noting down the caller in that function we can trace the code we have encountered during execution. Such information is used by coverage guided fuzzers like AFL and LibFuzzer to determine if a new input resulted in a new code path. This makes fuzzing much more effective. Additionally this adds a basic KCOV implementation. KCOV is an API that allows user space to request the kernel to start collecting coverage information for a given user space thread. Furthermore KCOV then exposes the collected program counters to user space via a BlockDevice which can be mmaped from user space. This work is required to add effective support for fuzzing SerenityOS to the Syzkaller syscall fuzzer. :^) :^)
2021-07-15Kernel: Make new kernel build process work on macOSGunnar Beutner
Use objcopy from the toolchain so that the changes introduced in 7236584 will succeed on macOS. Fixes #8768.
2021-07-14Meta: Remove obsolete `-fconcepts` CFLAGDaniel Bertalan
The GCC documentation says that since it's officially a part of C++20, this flag does nothing. Clang, however, does complain that it does not recognize it, so it's better to just remove it.
2021-07-12Meta+Documentation: Remove unused -DDEBUG from buildAndrew Kaster
2021-07-06Meta: Add the ConfigureComponents utilityMax Wipfli
This adds a utility program which is essentially a command generator for CMake. It reads the 'components.ini' file generated by CMake in the build directory, prompts the user to select a build type and optionally customize it, generates and runs a CMake command as well as 'ninja clean' and 'rm -rf Root', which are needed to properly remove system components. The program uses whiptail(1) for user interaction.
2021-07-04Toolchain+Userland: Enable TLS for x86_64Gunnar Beutner
This is not technically a toolchain change, but it does require rebuilding the toolchain for x86_64 (and just that).
2021-06-30Kernel: Disable __thread and TLS on x86_64 for nowGunnar Beutner
They're not yet properly supported.
2021-06-28Userland: Set linker max page size to 4096Gunnar Beutner
Neither the kernel nor LibELF support loading libraries with larger PT_LOAD alignment. The default on x86 is 4096 while it's 2MiB on x86_64. This changes the alignment to 4096 on all platforms.
2021-06-25Meta: Run 64-bit kernels with qemu-system-x86_64Gunnar Beutner
2021-06-18Userland/Libraries: Add LibUSBDB libraryJesse Buhagiar
Simple clone of LibPCIDB to support USB IDs instead of PCI ones. The format is basically identical, besides a few changes of the double tab fields.
2021-06-17Meta: Add support for declaring componentsGunnar Beutner
Components are a group of build targets that can be built and installed separately. Whether a component should be built can be configured with CMake arguments: -DBUILD_<NAME>=ON|OFF, where <NAME> is the name of the component (in all caps). Components can be marked as REQUIRED if they're necessary for a minimally functional base system or they can be marked as RECOMMENDED if they're not strictly necessary but are useful for most users. A component can have an optional description which isn't used by the build system but may be useful for a configuration UI. Components specify the TARGETS which should be built when the component is enabled. They can also specify other components which they depend on (with DEPENDS). This also adds the BUILD_EVERYTHING CMake variable which lets the user build all optional components. For now this defaults to ON to make the transition to the components-based build system easier. The list of components is exported as an INI file in the build directory (e.g. Build/i686/components.ini). Fixes #8048.
2021-06-09Meta: Disable -Wmaybe-uninitializedAli Mohammad Pur
It's prone to finding "technically uninitialized but can never happen" cases, particularly in Optional<T> and Variant<Ts...>. The general case seems to be that it cannot infer the dependency between Variant's index (or Optional's boolean state) and a particular alternative (or Optional's buffer) being untouched. So it can flag cases like this: ```c++ if (index == StaticIndexForF) new (new_buffer) F(move(*bit_cast<F*>(old_buffer))); ``` The code in that branch can _technically_ make a partially initialized `F`, but that path can never be taken since the buffer holding an object of type `F` and the condition being true are correlated, and so will never be taken _unless_ the buffer holds an object of type `F`. This commit also removed the various 'diagnostic ignored' pragmas used to work around this warning, as they no longer do anything.
2021-05-31CMake: Hide KMALLOC_VERIFY_NO_SPINLOCK_HELD so folks don't find itBrian Gianforcaro
Since I introduced this functionality there has been a steady stream of people building with `ALL_THE_DEBUG_MACROS` and trying to boot the system, and immediately hitting this assert. I have no idea why people try to build with all the debugging enabled, but I'm tired of seeing the bug reports about asserts we know are going to happen at this point. So I'm hiding this value under the new ENABLE_ALL_DEBUG_FACILITIES flag instead. This is only set by CI, and hopefully no-one will try to build with this thing (It's documented as not recommended). Fixes: #7527
2021-05-31CMake: Verify the GCC host version is new enough to build serenityBrian Gianforcaro
There are lots of people who have issues building serenity because they don't read the build directions closely enough and have an unsupported GCC version as their host compiler. Instead of repeatedly having to answer these kinds of questions, lets just error out upfront.