File: compiler-wrapper

package info (click to toggle)
simgrid 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 38,980 kB
  • sloc: cpp: 123,583; ansic: 66,779; python: 8,358; java: 6,406; fortran: 6,079; f90: 5,123; xml: 4,587; sh: 2,337; perl: 1,436; makefile: 105; lisp: 49; javascript: 7; sed: 6
file content (41 lines) | stat: -rwxr-xr-x 1,158 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python

# Copyright (c) 2014-2025. The SimGrid Team. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.

# Compiler wrapper with stack-cleaner support (enabled by default).
# Usage: ./compiler-wrapper target-compiler args [-f[no-]stack-cleaner]

import sys
import os
import re

compiler = sys.argv[1]
enabled = True
args = []

for arg in sys.argv[2:]:
    if arg == "--help":
        sys.stderr.write(
            "Compiler wrapper with stack-cleaner.\n"
            "Usage: {} compiler [-f[no-]stack-cleaner] [options]\n".format(sys.argv[0]))
        sys.exit(0)
    elif arg == "-fno-stack-cleaner":
        enabled = False
    elif arg == "-fstack-cleaner":
        enabled = True
    else:
        args.append(arg)

if enabled:
    if re.match("^clang", os.path.basename(compiler)):
        args.insert(0, "-no-integrated-as")
    args.insert(0, os.path.dirname(sys.argv[0]))
    args.insert(0, "-B")
args.insert(0, compiler)

os.execvp(args[0], args)
sys.stderr.write("compiler-wrapper: Could not exec\n")
os.exit(1)