File: gsl-compiler-arg.patch

package info (click to toggle)
brian 2.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,732 kB
  • sloc: python: 45,765; cpp: 1,832; ansic: 329; makefile: 113; sh: 64
file content (40 lines) | stat: -rw-r--r-- 1,879 bytes parent folder | download
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
Description: use generic compiler flags for GSL tests
 The Python module "brian" is capable of compiling code in some of its
 subsystems.  For performance purpose, the project defaults to aggressive
 compilation options.  This works relatively well on amd64.  However, compiler
 options are not consistent on all platforms.  Architectures based on IBM POWER
 use -mcpu=native and -mtune=native insteas of -march, and other architecture
 such as PA-RISC, RISC-V or Motorola 68000 have no "native" support of any sort.
 .
 This patch adapts the compiler options depending on the machine reported by
 uname.
Author: Étienne Mollier <etienne.mollier@mailoo.org>
Forwarded: https://github.com/brian-team/brian2/pull/1277
Last-Update: 2021-02-20
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/brian2/codegen/cpp_prefs.py
+++ b/brian2/codegen/cpp_prefs.py
@@ -120,6 +120,22 @@ if sys.platform == 'win32':
 else:
     prefix_dir = sys_prefix
 
+# Optimized default build options for a range a CPU architectures
+machine = os.uname().machine
+if re.match('^(x86_64|x32|aarch64|arm.*|s390.*|i.86.*)$', machine):
+    default_buildopts = ['-w', '-O3', '-ffast-math', '-fno-finite-math-only',
+                         '-march=native', '-std=c++11']
+elif re.match('^(alpha|ppc.*|sparc.*)$', machine):
+    default_buildopts = ['-w', '-O3', '-ffast-math', '-fno-finite-math-only',
+                         '-mcpu=native', '-mtune=native', '-std=c++11']
+elif re.match('^(sh|m68k|ia64|parisc.*|riscv.*|mips.*)$', machine):
+    default_buildopts = ['-w', '-O3', '-ffast-math', '-fno-finite-math-only',
+                         '-std=c++11']
+else:
+    print("warning: unknown machine, using safe default build options for",
+          machine, file=sys.stderr)
+    default_buildopts = ['-w']
+
 # Preferences
 prefs.register_preferences(
     'codegen.cpp',