cleanup - move linker lib imports to source code

This commit is contained in:
jacob 2024-04-03 02:33:29 -05:00
parent c3d395a44e
commit 59239ce13f
9 changed files with 41 additions and 39 deletions

View File

@ -137,14 +137,6 @@ target_precompile_headers(powerplay_exe PRIVATE src/common.h)
# Compiler flags
################################################################################
# Common flags
set(COMPILER_FLAGS "
-fno-strict-aliasing \
-fno-finite-loops \
-fwrapv \
-msse4.2 \
")
# TODO:
# Enable -
# -Wconversion \
@ -166,10 +158,20 @@ set(COMPILER_WARNINGS " \
")
# -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter
set(COMPILER_FLAGS "
-fno-strict-aliasing \
-fno-finite-loops \
-fwrapv \
-msse4.2 \
")
set(LINKER_FLAGS " \
-fuse-ld=lld-link \
${rc_res_sources} \
-luser32.lib -lkernel32.lib -lgdi32.lib -lshell32.lib -ldwmapi.lib -lole32.lib -ld3d11.lib -ld3dcompiler.lib -ldxgi.lib -ldxguid.lib -ldwrite.lib -lwinmm.lib -ladvapi32.lib -lmfplat.lib -lmfreadwrite.lib -lavrt.lib -lshlwapi.lib \
-fno-strict-aliasing \
-fno-finite-loops \
-fwrapv \
-msse4.2 \
")
# RTC (Runtime checks)
@ -179,38 +181,31 @@ if (RTC)
endif()
# Enable UBSan
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -fsanitize-trap=all -DRTC=1")
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined -fsanitize-trap=all")
# set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=undefined -DRTC=1")
# set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined")
endif()
# CRTLIB (C runtime library)
if (CRTLIB)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -DCRTLIB=1")
else()
set(COMPILER_FLAGS "${COMPILER_FLAGS} -mno-stack-arg-probe -fno-builtin")
set(LINKER_FLAGS "${LINKER_FLAGS} -nostdlib")
set(COMPILER_FLAGS "${COMPILER_FLAGS} -mno-stack-arg-probe -fno-builtin -nostdlib")
endif()
# Optimization
if (UNOPTIMIZED)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -O0 -DUNOPTIMIZED=1")
set(LINKER_FLAGS "${LINKER_FLAGS} -O0")
else()
set(COMPILER_FLAGS "${COMPILER_FLAGS} -O3 -flto")
set(LINKER_FLAGS "${LINKER_FLAGS} -O3 -flto -fwhole-program")
endif()
# Debug info
if (DEBINFO)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -g -DDEBINFO=1")
set(LINKER_FLAGS "${LINKER_FLAGS} -g")
endif()
# ASAN
if (ASAN)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=address -DASAN=1")
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address")
endif()
# Developer mode
@ -238,4 +233,4 @@ endif()
set(CMAKE_C_FLAGS "${COMPILER_FLAGS} ${COMPILER_WARNINGS} -std=c99")
set(CMAKE_CXX_FLAGS "${COMPILER_FLAGS} ${COMPILER_WARNINGS} -std=c++14")
set(CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${COMPILER_FLAGS} ${LINKER_FLAGS}")

View File

@ -30,7 +30,7 @@ where /q lld-link || (
echo ERROR: "lld-link.exe" not found - please run this from the MSVC x64 native tools command prompt.
exit /b 1
)
echo lld-link version:
echo lld-link version
lld-link --version
echo ---------------
@ -38,7 +38,7 @@ where /q ninja.exe || (
echo ERROR: "ninja.exe" not found - please run this from the MSVC x64 native tools command prompt.
exit /b 1
)
echo ninja version:
echo ninja version
ninja --version
echo ---------------

View File

@ -139,6 +139,7 @@ extern "C" {
/* Address sanitization */
#if ASAN
#pragma comment(lib, "clang_rt.asan-x86_64.lib")
void __asan_poison_memory_region(void *, size_t);
void __asan_unpoison_memory_region(void *, size_t);
# define ASAN_POISON(addr, size) __asan_poison_memory_region(addr, size);

View File

@ -10,7 +10,6 @@
#define MEMSET(ptr, val, count) memset(ptr, val, count)
#if CRTLIB
# include <memory.h>
#else

View File

@ -15,6 +15,10 @@
#include <mfreadwrite.h>
#include <Shlwapi.h>
#pragma comment(lib, "mfplat")
#pragma comment(lib, "mfreadwrite")
#pragma comment(lib, "shlwapi")
struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded, u32 flags)
{
struct mp3_decode_result res = { 0 };

View File

@ -20,6 +20,8 @@
#include <Audioclient.h>
#include <mmdeviceapi.h>
#pragma comment(lib, "avrt")
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xbcde0395, 0xe52f, 0x467c, 0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e);
DEFINE_GUID(IID_IMMDeviceEnumerator, 0xa95664d2, 0x9614, 0x4f35, 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6);
DEFINE_GUID(IID_IAudioClient, 0x1cb9ad4c, 0xdbfa, 0x4c32, 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2);

View File

@ -9,9 +9,6 @@
#include "tar.h"
#include <Windows.h>
#pragma warning(push)
#pragma warning(disable : 4201)
#pragma warning(disable : 4115)
#define CINTERFACE
#define COBJMACROS
#include <d3d11.h>
@ -20,7 +17,10 @@
#include <dxgi1_3.h>
#undef CINTERFACE
#undef COBJMACROS
#pragma warning(pop)
#pragma comment(lib, "d3d11")
#pragma comment(lib, "dxguid")
#pragma comment(lib, "d3dcompiler")
#define MAX_CANVASES 1024

View File

@ -18,6 +18,14 @@
#include <dwmapi.h>
#include <NTSecAPI.h>
#pragma comment(lib, "kernel32")
#pragma comment(lib, "user32")
#pragma comment(lib, "shell32")
#pragma comment(lib, "ole32")
#pragma comment(lib, "advapi32")
#pragma comment(lib, "winmm")
#pragma comment(lib, "dwmapi")
#define SYS_WINDOW_EVENT_LISTENERS_MAX 512
struct win32_thread_params {
@ -176,10 +184,7 @@ void *sys_memory_commit(void *address, u64 size)
void sys_memory_decommit(void *address, u64 size)
{
#pragma warning(push)
#pragma warning(disable : 6250) /* Disable warning "Calling 'VirtualFree' without MEM_RELEASE flag"*/
VirtualFree(address, size, MEM_DECOMMIT);
#pragma warning(pop)
}
/* ========================== *

View File

@ -1,27 +1,23 @@
/* Based on Allen Webster's dwrite rasterizer example -
* https://github.com/4th-dimention/examps */
#pragma warning( push, 0 )
#pragma warning(disable : 4576)
extern "C"
{
#include "ttf.h"
#include "scratch.h"
#include "util.h"
/* TODO: remove this */
#include "string.h"
#include "memory.h"
#include "arena.h"
#include "font.h"
}
#pragma warning( pop )
#include <dwrite.h>
//#include <dwrite_1.h>
#include <dwrite_3.h>
#pragma comment(lib, "dwrite")
#pragma comment(lib, "gdi32")
/* TODO: Determine DPI accurately? */
#define DPI (96.0f)