mirror of https://github.com/PCSX2/pcsx2.git
Changes to update build process with focus on building manually with clang/llvm
parent
43955e4c1b
commit
39e3eb429e
|
@ -1,137 +1,66 @@
|
|||
# Warning
|
||||
## Introduction
|
||||
|
||||
This page is likely out of date with the current process to build PCSX2. You should follow the same steps as our CI:
|
||||
This guide demonstrates how to build PCSX2 in Linux environments. Note that the steps provided below may vary depending on the distribution - such variances are not officially supported by the PCSX2 team.
|
||||
|
||||
Note that the procedure defined herein closely mirrors the scripts used by the PCSX2 CI process. These scripts provide more information behind the build process than what is stated here.
|
||||
- https://github.com/PCSX2/pcsx2/blob/master/.github/workflows/linux_build_qt.yml
|
||||
- https://github.com/PCSX2/pcsx2/tree/master/.github/workflows/scripts/linux
|
||||
|
||||
## Index
|
||||
## Dependencies
|
||||
|
||||
1. [Introduction](#introduction)
|
||||
2. [CMake Build System](#using-cmake)
|
||||
3. [Debugging](#debugging)
|
||||
4. [Outdated](#on-to-some-outdated-stuff)
|
||||
Note that dependencies tend to change over time, along with their required versions. In particular, PCSX2 no longer supports the gcc compiler, as it has transitioned to clang/llvm due to the many benefits the latter compiler offers, including superior efficiency and speed.
|
||||
|
||||
## Introduction
|
||||
### Build system
|
||||
|
||||
This is intended to give you an idea of how to compile PCSX2 from Git in Linux. Some of the steps may be different on some versions of Linux, and this is not generally supported by the PCSX2 team. If you have issues following this guide, I'd recommend going through this thread for help: https://forums.pcsx2.net/Thread-Linux-Compile-Guide-and-Support
|
||||
- `clang` >= 17.0.6
|
||||
- `cmake`
|
||||
- `git`
|
||||
- `lld` >= 17.0.6
|
||||
- `llvm` >= 17.0.6
|
||||
- `ninja`
|
||||
|
||||
### Libraries
|
||||
|
||||
### Arch Linux build dependencies
|
||||
- `libaio`
|
||||
- `libpng`
|
||||
- `libx11`
|
||||
- `qt` >= 6.6.1
|
||||
- `sdl2` >= 2.28.5
|
||||
- `soundtouch`
|
||||
- `xz`
|
||||
|
||||
#### Build system
|
||||
## Build procedure
|
||||
|
||||
You need:
|
||||
`gcc`, `cmake`, `git`
|
||||
### Clone repository
|
||||
|
||||
Optionally, you can build with:
|
||||
|
||||
`clang`, `lld`, & `ninja`
|
||||
|
||||
#### Libraries. Dependencies may change in the future
|
||||
|
||||
`libaio` `libpng` `sdl2` `soundtouch` `libx11` `xz`
|
||||
|
||||
### Using CMake
|
||||
|
||||
#### Basic mode: straightforward compilation
|
||||
|
||||
Use one of the cmake presets:
|
||||
`mkdir build && cd build && cmake --preset=<preset> ..` and then either `make -j <cores>` or `ninja`, depending on the preset.
|
||||
|
||||
For clang, lld, and ninja, use `clang-debug`, `clang-devel`, or `clang-release`. This is currently the only lto preset.
|
||||
|
||||
#### Expert mode: CMake build parameters
|
||||
|
||||
Basic parameters:
|
||||
- Use Release/Development/Debug : `-DCMAKE_BUILD_TYPE=Release|Devel|Debug`
|
||||
- `Release`: Best in speed, but provides little or no debug/crash info.
|
||||
- `Devel`: Adds detailed trace logging abilities, but still lacks debug/crash info.
|
||||
- `Debug`: No compiler optimizations. Very good for debug/crash info but also very slow.
|
||||
|
||||
### Running CMake to generate the makefile:
|
||||
|
||||
It is advised to use a build method that places build files outside the PCSX2 sources directory, as it makes it easier to delete all CMake build files:
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake .. <other options>
|
||||
git clone --recursive https://github.com/PCSX2/pcsx2.git
|
||||
cd pcsx2
|
||||
```
|
||||
|
||||
#### Do the compilation:
|
||||
### Prepare build with CMake
|
||||
|
||||
Either:
|
||||
```
|
||||
make -j <jobs. Should be the number of cores you have. 4/6'll probably be fine>
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_C_COMPILER=<path_to_clang> -DCMAKE_CXX_COMPILER=<path_to_clang++> -DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld" -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld" -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld" -GNinja ..
|
||||
```
|
||||
|
||||
or, if you are a ninja, or at least using ninja:
|
||||
Note the following optional CMake flags that are commonly used:
|
||||
|
||||
- `-DCMAKE_BUILD_TYPE=Release|Devel|Debug`
|
||||
- `Release`: Fastest build, but lacks debug/crash information
|
||||
- `Devel`: Adds detailed trace logging abilities, but lacks debug/crash information
|
||||
- `Debug`: Slowest build as there are no compiler optimizations, but offers debug/crash information
|
||||
|
||||
- `-DCMAKE_CXX_COMPILER_LAUNCHER=ccache`
|
||||
- Uses ccache to speed up the build process
|
||||
|
||||
- `-DCMAKE_PREFIX_PATH=<path>`
|
||||
- Defines paths to system libraries that are not globally recognized within the build environment. For example, if SDL2 is manually installed from a source outside its official repository, then its path can be defined here.
|
||||
|
||||
### Execute build
|
||||
|
||||
```
|
||||
ninja
|
||||
```
|
||||
|
||||
### Reporting CMake bugs
|
||||
|
||||
Not all distributions and configurations were tested. In case you encounter a CMake bug that is really a CMake issue, you can report it. Please provide the following information:
|
||||
|
||||
1. Linux distribution, the current kernel version, and architecture (32-bit or 64-bit)
|
||||
2. The CMake commands. For example: `cmake CMakeLists.txt`
|
||||
3. **All** of CMake's output. Something like this is good:
|
||||
|
||||
```
|
||||
-- The C compiler identification is GNU
|
||||
-- The CXX compiler identification is GNU
|
||||
-- Check for working C compiler: /usr/bin/gcc
|
||||
-- Check for working C compiler: /usr/bin/gcc -- works
|
||||
-- Detecting C compiler ABI info
|
||||
-- Detecting C compiler ABI info - done
|
||||
-- Check for working CXX compiler: /usr/bin/c++
|
||||
-- Check for working CXX compiler: /usr/bin/c++ -- works
|
||||
-- Detecting CXX compiler ABI info
|
||||
-- Detecting CXX compiler ABI info - done
|
||||
-- Found GTK2_GTK: /usr/lib/libgtk-x11-2.0.so
|
||||
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
|
||||
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
|
||||
-- Looking for gethostbyname
|
||||
-- Looking for gethostbyname - found
|
||||
-- Looking for connect
|
||||
-- Looking for connect - found
|
||||
-- Looking for remove
|
||||
-- Looking for remove - found
|
||||
-- Looking for shmat
|
||||
-- Looking for shmat - found
|
||||
-- Looking for IceConnectionNumber in ICE
|
||||
-- Looking for IceConnectionNumber in ICE - found
|
||||
-- Found X11: /usr/lib/libX11.so
|
||||
-- Found ALSA: /usr/lib/libasound.so
|
||||
-- Found BZip2: /usr/lib/libbz2.so
|
||||
-- Looking for BZ2_bzCompressInit in /usr/lib/libbz2.so
|
||||
-- Looking for BZ2_bzCompressInit in /usr/lib/libbz2.so - found
|
||||
-- Looking for include files CMAKE_HAVE_PTHREAD_H
|
||||
-- Looking for include files CMAKE_HAVE_PTHREAD_H - found
|
||||
-- Looking for pthread_create in pthreads
|
||||
-- Looking for pthread_create in pthreads - not found
|
||||
-- Looking for pthread_create in pthread
|
||||
-- Looking for pthread_create in pthread - found
|
||||
-- Found Threads: TRUE
|
||||
-- Found wxWidgets: TRUE
|
||||
-- Found ZLIB: /usr/lib/libz.so
|
||||
-- Found Cg: /usr/lib/libCg.so;/usr/lib/libCgGL.so
|
||||
-- Found PortAudio: /usr/lib/libportaudio.so
|
||||
-- Found SoundTouch: /usr/lib/libSoundTouch.so
|
||||
-- Configuring done
|
||||
-- Generating done
|
||||
-- Build files have been written to: /mnt/playstation/emulateur/package/pcsx2.snapshot-4810
|
||||
```
|
||||
|
||||
## Debugging
|
||||
|
||||
It can be helpful to run PCSX2 under [GDB](https://www.gnu.org/software/gdb/) in order to set breakpoints and debug crashes.
|
||||
|
||||
To enable debugging with symbol names, use `-DCMAKE_BUILD_TYPE=Debug`.
|
||||
|
||||
The built executable can then be debugged using `gdb ./bin/pcsx2-qt`. You will need to disable segfault catching with `process handle SIGSEGV nostop noprint`.
|
||||
|
||||
### Segmentation Faults
|
||||
|
||||
Segmentation faults (`SIGSEGV`) are [expected](https://github.com/PCSX2/pcsx2/issues/1806#issuecomment-278268282) when running recompiled code such as a game in PCSX2. When a segmentation fault occurs, use `bt` and check if the backtrace contains `recExecute`. If it does then continue execution using `c`.
|
||||
|
||||
Additionally, segfault printing can be disabled entirely in GDB using the command `handle SIGSEGV noprint`.
|
||||
```
|
Loading…
Reference in New Issue