Skip to content

Commit 43e5be3

Browse files
committed
Merge branch 'master' into for-0.56.0/sync
2 parents be32933 + 17e9107 commit 43e5be3

37 files changed

+890
-439
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ endif()
465465
include(DaemonNacl)
466466
if (NACL)
467467
add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE})
468-
set_target_properties(srclibs-nacl-module PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs")
469468
set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module)
470469
else()
471470
add_library(srclibs-nacl-native EXCLUDE_FROM_ALL ${NACLLIST_NATIVE})

cmake/DaemonFlags.cmake

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,12 @@ else()
363363
endif()
364364

365365
if (NACL AND USE_NACL_SAIGO AND SAIGO_ARCH STREQUAL "arm")
366-
# This should be set for every build type because build type flags
367-
# are set after the other custom flags and then have the last word.
368-
# DEBUG should already use -O0 anyway.
366+
# Saigo produces broken arm builds when optimizing them.
369367
# See: https://github.com/Unvanquished/Unvanquished/issues/3297
370-
set_c_cxx_flag("-O0" DEBUG)
371-
set_c_cxx_flag("-O0" RELEASE)
372-
set_c_cxx_flag("-O0" RELWITHDEBINFO)
373-
set_c_cxx_flag("-O0" MINSIZEREL)
368+
# When setting this clang-specific option, we don't have to care
369+
# about the ordering of -O options that may be introduced,
370+
# all -O options added to the command line are ignored.
371+
set_c_cxx_flag("-Xclang -disable-llvm-passes")
374372
endif()
375373

376374
# Extra debug flags.
@@ -476,7 +474,16 @@ else()
476474
# Don't set _FORTIFY_SOURCE in debug builds.
477475
endif()
478476

479-
try_c_cxx_flag(FPIC "-fPIC")
477+
if (NOT NACL)
478+
# Saigo reports weird errors when building some cgame and sgame arm nexe with PIC:
479+
# > error: Cannot represent a difference across sections
480+
# > error: expected relocatable expression
481+
# Google-built Saigo crashes when building amd64 cgame with PIC:
482+
# > UNREACHABLE executed at llvm/lib/Target/X86/X86ISelLowering.cpp
483+
# Self-built Saigo doesn't crash, maybe because assertions are disabled.
484+
# PIC is not useful with NaCl under any circumstances, so we don't use PIC with NaCl.
485+
try_c_cxx_flag(FPIC "-fPIC")
486+
endif()
480487

481488
if (USE_HARDENING)
482489
# PNaCl accepts the flags but does not define __stack_chk_guard and __stack_chk_fail.
@@ -491,7 +498,7 @@ else()
491498
try_c_cxx_flag(FNO_STRICT_OVERFLOW "-fno-strict-overflow")
492499
try_c_cxx_flag(WSTACK_PROTECTOR "-Wstack-protector")
493500

494-
if (NOT NACL OR (NACL AND GAME_PIE))
501+
if (NOT NACL)
495502
# The -pie flag requires -fPIC:
496503
# > ld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC
497504
# This flag isn't used on macOS:
@@ -693,6 +700,13 @@ if (APPLE)
693700
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
694701
endif()
695702

703+
# Glibc-specific definitions
704+
if (LINUX)
705+
# QUIRK: It does nothing when it is not needed on non-glibc Linux
706+
# systems so it's harmless to always set it.
707+
add_definitions(-D_FILE_OFFSET_BITS=64)
708+
endif()
709+
696710
# Configuration specific definitions
697711

698712
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<${DEBUG_GENEXP_COND}:DEBUG_BUILD>)

cmake/DaemonPlatform.cmake

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,5 @@ else()
4040
message( FATAL_ERROR "Platform not supported" )
4141
endif()
4242

43-
if (NACL AND USE_NACL_SAIGO)
44-
# Saigo clang reports weird errors when building some cgame and sgame arm nexe with PIE.
45-
# Saigo clang crashes when building amd64 cgame with PIE, sgame builds properly though.
46-
set(GAME_PIE 0)
47-
else()
48-
set(GAME_PIE 1)
49-
endif()
50-
51-
5243
include(DaemonArchitecture)
5344
include(DaemonCompiler)

src/common/FileSystem.cpp

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
#include "minizip/unzip.h"
3333
#endif
3434

35+
#if defined(__GLIBC__)
36+
#if !defined(_FILE_OFFSET_BITS) || (_FILE_OFFSET_BITS != 64)
37+
#error _FILE_OFFSET_BITS should be set to 64 on glibc
38+
#endif
39+
#endif
40+
3541
#ifdef BUILD_VM
3642
#include "shared/VMMain.h"
3743
#else
@@ -175,6 +181,7 @@ enum class openMode_t {
175181
MODE_APPEND,
176182
MODE_EDIT
177183
};
184+
178185
inline int my_open(Str::StringRef path, openMode_t mode)
179186
{
180187
int mode_ = Util::ordinal(mode);
@@ -192,14 +199,10 @@ inline int my_open(Str::StringRef path, openMode_t mode)
192199
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(h), modes[mode_] | O_BINARY | O_NOINHERIT);
193200
if (fd == -1)
194201
CloseHandle(h);
195-
#elif defined(__FreeBSD__) || defined(__APPLE__)
196-
// O_CLOEXEC is supported in macOS from 10.7 onwards
202+
#else
203+
// This doesn't actually work in Native Client, but it's not used anyways.
204+
// O_CLOEXEC is supported in macOS from 10.7 onwards.
197205
int fd = open(path.c_str(), modes[mode_] | O_CLOEXEC, 0666);
198-
#elif defined(__linux__)
199-
int fd = open64(path.c_str(), modes[mode_] | O_CLOEXEC | O_LARGEFILE, 0666);
200-
#elif defined(__native_client__)
201-
// This doesn't actually work, but it's not used anyways
202-
int fd = open(path.c_str(), modes[mode_], 0666);
203206
#endif
204207

205208
#ifndef _WIN32
@@ -238,47 +241,37 @@ inline offset_t my_ftell(FILE* fd)
238241
{
239242
#ifdef _WIN32
240243
return _ftelli64(fd);
241-
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__)
244+
#else
242245
return ftello(fd);
243-
#elif defined(__linux__)
244-
return ftello64(fd);
245246
#endif
246247
}
247248
inline int my_fseek(FILE* fd, offset_t off, int whence)
248249
{
249250
#ifdef _WIN32
250251
return _fseeki64(fd, off, whence);
251-
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__)
252+
#else
252253
return fseeko(fd, off, whence);
253-
#elif defined(__linux__)
254-
return fseeko64(fd, off, whence);
255254
#endif
256255
}
257256
#ifdef _WIN32
258257
typedef struct _stati64 my_stat_t;
259-
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__)
258+
#else
260259
using my_stat_t = struct stat;
261-
#elif defined(__linux__)
262-
using my_stat_t = struct stat64;
263260
#endif
264261
inline int my_fstat(int fd, my_stat_t* st)
265262
{
266263
#ifdef _WIN32
267264
return _fstati64(fd, st);
268-
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__)
265+
#else
269266
return fstat(fd, st);
270-
#elif defined(__linux__)
271-
return fstat64(fd, st);
272267
#endif
273268
}
274269
inline int my_stat(Str::StringRef path, my_stat_t* st)
275270
{
276271
#ifdef _WIN32
277272
return _wstati64(Str::UTF8To16(path).c_str(), st);
278-
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__)
273+
#else
279274
return stat(path.c_str(), st);
280-
#elif defined(__linux__)
281-
return stat64(path.c_str(), st);
282275
#endif
283276
}
284277
inline intptr_t my_pread(int fd, void* buf, size_t count, offset_t offset)
@@ -294,10 +287,8 @@ inline intptr_t my_pread(int fd, void* buf, size_t count, offset_t offset)
294287
return -1;
295288
}
296289
return bytesRead;
297-
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(__native_client__)
290+
#else
298291
return pread(fd, buf, count, offset);
299-
#elif defined(__linux__)
300-
return pread64(fd, buf, count, offset);
301292
#endif
302293
}
303294

0 commit comments

Comments
 (0)