-
Notifications
You must be signed in to change notification settings - Fork 19
/
linux.txt
112 lines (98 loc) · 5.77 KB
/
linux.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
PROBLEMS/BUGS (LINUX/CYGWIN):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
? build.sh: timing info format incorrect (linux) -- 31.01.2006: all OK?!
- linux testapp.cpp display warning about gets(); cygwin - no warning! (linker message)
! libs.a/libs.lib: should change name to contain platform name, add linux to libs/build.sh
GCC 4.0+ BUGS:
~~~~~~~~~~~~~
- (4.1:exists) when creating mapfile, names not demangled
* demangling was moved from "ld" to "syminfo/make"
- (4.1:exists) visibility: `#pragma GCC visibility' not affects builtin functions, so - conflicts ... (displays warnings about
trying to hide built-in visible function `operator new')
- should use "-fvisibility..." cmdline instead of "#pragma GCC visibility ..."; make auto-detect of gcc4 from makefile:
GCC_VER = $(shell echo __GNUC__ | gcc -E -xc - | tail -n 1)
# also: __GCC_MINOR__
ifeq ($(GCC_VER),4) / ifneq () ... (no -gt/-lt etc -- should use $(shell if [...] ...;))
- (4.1:exists) inlining: not inlined most of functions (can check with `-Winlines') - compiler says 'max-inline-insns-single reached',
which, by info page, should be inline-limit/2 (by default, inline-limit=600 -- by info page)
* may be fixed by inserting `--finline-limit=600', which is default (by documentation) value (should be automatic!)
NOTE: inlining required for `operator new' and similar functions to take advantage of `mem_dump' console functions --
* fixed using FORCEINLINE; other inline functions not inlined anyway (-Winline)!
------- REQUIREMENTS --------
min GCC version: 3.4.0
3.3.2 have no:
-Wno-invalid-offsetof
- error in Core/Strings.h with PRINTF() macro?
... not tested more
TODO:
~~~~~
- fast math - make ability to turn off with #define (for debug; may be, GCC optimizes good by self ...)
- floor/ceil/round: not so fast ... (check GCC FAST_MATH ...); appRound() via lrint() rounds 2.5 and 4.5 to 3 (same as VC ...)
- assert(cond) or UT-like check() and verify()
- special code to test fast math functions (appRsqrt, appFloor, IsNegative, FAbsSign, ...) -- exec function + compare with non-fast
equalent; allow small error; exec inside loop to disallow compile-time computations (either iterate values, or use table ...)
GCC TODO:
~~~~~~~~~
? mingw32 exception system (used exception/signal -> C++ throw before ...); currently uses setjmp() exception path (does works,
but cannot catch "error -stack" -- mingw32/cygwin problem -- no separate signal stack)
- may be, access to SDK/includes from src as '#include <*>' instead of '#include "*"'
- asm constructions:
- check floor/ceil/round (implement asm? check mingw math.h header for some details)
! compare VC/GCC speed (after floor/ceil/round -> GCC asm)
- "-ffunction-sections" slightly increase exe size; "-fdata-sections" grow q2 executable size up to 5 Mb ?!
- structure copy (for CVec3) is per-element (not memcpy())
To port application to Linux require following steps:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* port Core/*Win32.cpp
* exception hook: use signal() functions
* compile TestApp
- make net_wins.cpp cross-platform (initial: can create "empty" net device with loopback caps)
! should redesign networking lower level unit
- create sys_win.cpp for Linux
? may be, create set of MainLoop wrappers in Core headers -- or set of main()/WinMain() functions, and app should
provide MainLoop() only?
- compile dedicated server (1.cygwin 2.linux)
- verify network compatibility with Win32
- ...
- create empty sound driver, use it for "nosound=1" (?)
- port input+windowing -> SDL (may use cygwin+sdl !)
- ...
- separate sound driver from client code
- create OpenAL sound driver, use for win32 too
? may be, create SDL sound driver too (in a case of absece OpenAL library)
- ...
To allow binaries to work under any Linux version/distribution:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- use static linkage with C++ libraries (libstdc++.so.6 etc)
- libstdc++.so: should be dynamic to allow inter-module exceptions (not used here)
* tried linux of 2001 year (kernel 2.2, KDE 2.1, libc is v6) -- libc.so.6 requires LIBC2_... exports
(so - build with static libc too? -- or static/shared versions?)
? may be, do not need to support old linux versions - build for current versions, but ensure, upgrading linux
will not break binary/library compatibility
- may be, statically link with all modules (app and system)
GCC notes:
~~~~~~~~~~
* appGetSystemErrorMessage() -- strerror(code)
* #pragma(pack...) -- struct name __attribute__((__packed__)) {}
(note: may use __attribute__((packed)) instead
- function attributes:
- warn_usused_result - warning, when result of function ignored
- constructor/destructor - call function before main()/exit()
- format_arg(index) - arg #index is printf-like format specifier
- DLL_IMPORT/DLL_EXPORT:
* use __attribute__((visibility))
- check "dsohowto.pdf" chapter 2.2 (seems, require GCC 4+ or patched compiler)
- check misc/compilers/GCC_Visibility.htm
- varargs in macros (see GCC doc 5.15)
- type_t varName; "typeof(varName) varName2" == "type_t varName2"
- __func__ macro: "const char name[]" of current function
- i386 type attribute: ms_struct, gcc_struct
- to create dynamic build: use "ld -rpath ..." cmdline arg to allow placing engine .so files into non-standard dirs
----------------------------------------------------------
"Proc" file system:
* /proc/version -- OS version (can use uname())
/proc/cpuinfo -- CPU information (can use for non-x86 or when no CPUID support)
* /proc/%d -- some process information (%d == pid); can use "self" instead of %d
cmdline -- very similar to argv[]; useless for self (but may be used to obtain cmdlines of other processes)
* exename
* maps -- which exe/dll/so loaded (2.4); WARNING: linux and cygwin have different "offset" meaning! (cygwin => entry point)