mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 11:11:47 +02:00
Move checking for compiler brand into Env
This commit is contained in:
13
glfw/glfw.py
13
glfw/glfw.py
@@ -5,6 +5,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple
|
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Sequence, Tuple
|
||||||
@@ -79,10 +80,22 @@ class Env:
|
|||||||
self.vcs_rev = vcs_rev
|
self.vcs_rev = vcs_rev
|
||||||
self.binary_arch = binary_arch
|
self.binary_arch = binary_arch
|
||||||
self.native_optimizations = native_optimizations
|
self.native_optimizations = native_optimizations
|
||||||
|
self._cc_version_string = ''
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cc_version_string(self) -> str:
|
||||||
|
if not self._cc_version_string:
|
||||||
|
self._cc_version_string = subprocess.check_output(self.cc + ['--version']).decode()
|
||||||
|
return self._cc_version_string
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_gcc(self) -> bool:
|
||||||
|
return '(GCC)' in self.cc_version_string
|
||||||
|
|
||||||
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)
|
||||||
ans.all_headers = list(self.all_headers)
|
ans.all_headers = list(self.all_headers)
|
||||||
|
ans._cc_version_string = self._cc_version_string
|
||||||
ans.sources = list(self.sources)
|
ans.sources = list(self.sources)
|
||||||
ans.wayland_packagedir = self.wayland_packagedir
|
ans.wayland_packagedir = self.wayland_packagedir
|
||||||
ans.wayland_scanner = self.wayland_scanner
|
ans.wayland_scanner = self.wayland_scanner
|
||||||
|
|||||||
21
setup.py
21
setup.py
@@ -431,16 +431,6 @@ def set_arches(flags: List[str], *arches: str) -> None:
|
|||||||
flags.extend(('-arch', arch))
|
flags.extend(('-arch', arch))
|
||||||
|
|
||||||
|
|
||||||
def is_gcc(cc: Iterable[str]) -> bool:
|
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def f(cc: Tuple[str]) -> bool:
|
|
||||||
raw = subprocess.check_output(cc + ('--version',)).decode('utf-8').splitlines()[0]
|
|
||||||
return '(GCC)' in raw.split()
|
|
||||||
|
|
||||||
return f(tuple(cc))
|
|
||||||
|
|
||||||
|
|
||||||
def init_env(
|
def init_env(
|
||||||
debug: bool = False,
|
debug: bool = False,
|
||||||
sanitize: bool = False,
|
sanitize: bool = False,
|
||||||
@@ -465,7 +455,7 @@ def init_env(
|
|||||||
print('CC:', cc, ccver)
|
print('CC:', cc, ccver)
|
||||||
stack_protector = first_successful_compile(cc, '-fstack-protector-strong', '-fstack-protector')
|
stack_protector = first_successful_compile(cc, '-fstack-protector-strong', '-fstack-protector')
|
||||||
missing_braces = ''
|
missing_braces = ''
|
||||||
if ccver < (5, 2) and is_gcc(cc):
|
if ccver < (5, 2):
|
||||||
missing_braces = '-Wno-missing-braces'
|
missing_braces = '-Wno-missing-braces'
|
||||||
df = '-g3'
|
df = '-g3'
|
||||||
float_conversion = ''
|
float_conversion = ''
|
||||||
@@ -568,10 +558,13 @@ def init_env(
|
|||||||
if native_optimizations and ba.isa in (ISA.AMD64, ISA.X86):
|
if native_optimizations and ba.isa in (ISA.AMD64, ISA.X86):
|
||||||
cflags.extend('-march=native -mtune=native'.split())
|
cflags.extend('-march=native -mtune=native'.split())
|
||||||
|
|
||||||
return Env(
|
ans = Env(
|
||||||
cc, cppflags, cflags, ldflags, library_paths, binary_arch=ba, native_optimizations=native_optimizations,
|
cc, cppflags, cflags, ldflags, library_paths, binary_arch=ba, native_optimizations=native_optimizations,
|
||||||
ccver=ccver, ldpaths=ldpaths, vcs_rev=vcs_rev,
|
ccver=ccver, ldpaths=ldpaths, vcs_rev=vcs_rev,
|
||||||
)
|
)
|
||||||
|
if verbose:
|
||||||
|
print(ans.cc_version_string)
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
def kitty_env(args: Options) -> Env:
|
def kitty_env(args: Options) -> Env:
|
||||||
@@ -714,7 +707,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 is_gcc(env.cc):
|
if env.is_gcc:
|
||||||
ans.append('-mno-vzeroupper')
|
ans.append('-mno-vzeroupper')
|
||||||
else:
|
else:
|
||||||
ans.append('-mllvm')
|
ans.append('-mllvm')
|
||||||
@@ -1183,7 +1176,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 is_gcc(env.cc) else []
|
libs += ['-lasan'] if not is_macos and env.is_gcc else []
|
||||||
else:
|
else:
|
||||||
cflags.append('-g')
|
cflags.append('-g')
|
||||||
if args.profile:
|
if args.profile:
|
||||||
|
|||||||
Reference in New Issue
Block a user