mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 09:48:09 +02:00
Explicitly detect compiler types gcc vs clang
This commit is contained in:
19
glfw/glfw.py
19
glfw/glfw.py
@@ -46,6 +46,12 @@ class BinaryArch(NamedTuple):
|
|||||||
isa: ISA = ISA.AMD64
|
isa: ISA = ISA.AMD64
|
||||||
|
|
||||||
|
|
||||||
|
class CompilerType(Enum):
|
||||||
|
gcc = 'gcc'
|
||||||
|
clang = 'clang'
|
||||||
|
unknown = 'unknown'
|
||||||
|
|
||||||
|
|
||||||
class Env:
|
class Env:
|
||||||
|
|
||||||
cc: List[str] = []
|
cc: List[str] = []
|
||||||
@@ -80,6 +86,7 @@ class Env:
|
|||||||
self.binary_arch = binary_arch
|
self.binary_arch = binary_arch
|
||||||
self.native_optimizations = native_optimizations
|
self.native_optimizations = native_optimizations
|
||||||
self._cc_version_string = ''
|
self._cc_version_string = ''
|
||||||
|
self._compiler_type: Optional[CompilerType] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cc_version_string(self) -> str:
|
def cc_version_string(self) -> str:
|
||||||
@@ -88,8 +95,16 @@ class Env:
|
|||||||
return self._cc_version_string
|
return self._cc_version_string
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_clang(self) -> bool:
|
def compiler_type(self) -> CompilerType:
|
||||||
return 'clang' in self.cc_version_string.split()
|
if self._compiler_type is None:
|
||||||
|
raw = self.cc_version_string
|
||||||
|
if 'Free Software Foundation' in raw:
|
||||||
|
self._compiler_type = CompilerType.gcc
|
||||||
|
elif 'clang' in raw.lower().split():
|
||||||
|
self._compiler_type = CompilerType.clang
|
||||||
|
else:
|
||||||
|
self._compiler_type = CompilerType.unknown
|
||||||
|
return self._compiler_type
|
||||||
|
|
||||||
def copy(self) -> 'Env':
|
def copy(self) -> 'Env':
|
||||||
ans = Env(self.cc, list(self.cppflags), list(self.cflags), list(self.ldflags), dict(self.library_paths), list(self.ldpaths), self.ccver)
|
ans = Env(self.cc, list(self.cppflags), list(self.cflags), list(self.ldflags), dict(self.library_paths), list(self.ldpaths), self.ccver)
|
||||||
|
|||||||
6
setup.py
6
setup.py
@@ -23,7 +23,7 @@ from pathlib import Path
|
|||||||
from typing import Callable, Dict, FrozenSet, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Union, cast
|
from typing import Callable, Dict, FrozenSet, Iterable, Iterator, List, Optional, Sequence, Set, Tuple, Union, cast
|
||||||
|
|
||||||
from glfw import glfw
|
from glfw import glfw
|
||||||
from glfw.glfw import ISA, BinaryArch, Command, CompileKey
|
from glfw.glfw import ISA, BinaryArch, Command, CompileKey, CompilerType
|
||||||
|
|
||||||
if sys.version_info[:2] < (3, 8):
|
if sys.version_info[:2] < (3, 8):
|
||||||
raise SystemExit('kitty requires python >= 3.8')
|
raise SystemExit('kitty requires python >= 3.8')
|
||||||
@@ -701,7 +701,7 @@ def get_source_specific_cflags(env: Env, src: str) -> List[str]:
|
|||||||
ans.append('-msse4.2' if '128' in src else '-mavx2')
|
ans.append('-msse4.2' if '128' in src else '-mavx2')
|
||||||
if '256' in src:
|
if '256' in src:
|
||||||
# We have manual vzeroupper so prevent compiler from emitting it causing duplicates
|
# We have manual vzeroupper so prevent compiler from emitting it causing duplicates
|
||||||
if env.is_clang:
|
if env.compiler_type is CompilerType.clang:
|
||||||
ans.append('-mllvm')
|
ans.append('-mllvm')
|
||||||
ans.append('-x86-use-vzeroupper=0')
|
ans.append('-x86-use-vzeroupper=0')
|
||||||
else:
|
else:
|
||||||
@@ -1170,7 +1170,7 @@ def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 's
|
|||||||
sanitize_args = get_sanitize_args(env.cc, env.ccver)
|
sanitize_args = get_sanitize_args(env.cc, env.ccver)
|
||||||
cflags.extend(sanitize_args)
|
cflags.extend(sanitize_args)
|
||||||
ldflags.extend(sanitize_args)
|
ldflags.extend(sanitize_args)
|
||||||
libs += ['-lasan'] if not is_macos and not env.is_clang else []
|
libs += ['-lasan'] if not is_macos and env.compiler_type is not CompilerType.clang else []
|
||||||
else:
|
else:
|
||||||
cflags.append('-g')
|
cflags.append('-g')
|
||||||
if args.profile:
|
if args.profile:
|
||||||
|
|||||||
Reference in New Issue
Block a user