Skip to content
Snippets Groups Projects
Commit 9c3171bc authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[machdep] more robust generator

- --compile-flags="-c -I/path" works (i.e. there's no need to provide as many
  --compile-flags options as you have flags to pass to the compiler itself.
  Ditto for --cpp-arch-flags of course
- we start by checking that a minimal C file does not trigger a compiler error
  with the given option and we abort otherwise. This ensures that subsequent
  tests will not mistakenly take a configuration error for a genuine result.
parent 85aabb77
No related branches found
No related tags found
No related merge requests found
...@@ -176,9 +176,15 @@ def make_machdep(): ...@@ -176,9 +176,15 @@ def make_machdep():
machdep = make_machdep() machdep = make_machdep()
compilation_command = [args.compiler] + args.cpp_arch_flags + args.compiler_flags compilation_command = [args.compiler]
for flag in args.cpp_arch_flags + args.compiler_flags:
compilation_command = compilation_command + flag.split(" ")
source_files = [ source_files = [
# sanity_check is juste here to ensure that the given compiler
# and flags are coherent. It must be kept at the top of the list.
("sanity_check.c", "none"),
("sizeof_short.c", "number"), ("sizeof_short.c", "number"),
("sizeof_int.c", "number"), ("sizeof_int.c", "number"),
("sizeof_long.c", "number"), ("sizeof_long.c", "number"),
...@@ -317,6 +323,12 @@ for f, typ in source_files: ...@@ -317,6 +323,12 @@ for f, typ in source_files:
print(f"[INFO] running command: {' '.join(cmd)}") print(f"[INFO] running command: {' '.join(cmd)}")
proc = subprocess.run(cmd, capture_output=True) proc = subprocess.run(cmd, capture_output=True)
Path(f).with_suffix(".o").unlink(missing_ok=True) Path(f).with_suffix(".o").unlink(missing_ok=True)
if typ == "none":
if proc.returncode != 0:
logging.critical("cannot compile sample C file with provided compiler and flags.")
logging.info(f"compiler output is:{proc.stderr.decode()}")
sys.exit(1)
continue
if typ == "macro": if typ == "macro":
if proc.returncode != 0: if proc.returncode != 0:
logging.warning(f"error in preprocessing value '{p}', some values won't be filled") logging.warning(f"error in preprocessing value '{p}', some values won't be filled")
......
/**************************************************************************/
/* */
/* This file is part of Frama-C. */
/* */
/* Copyright (C) 2007-2023 */
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* you can redistribute it and/or modify it under the terms of the GNU */
/* Lesser General Public License as published by the Free Software */
/* Foundation, version 2.1. */
/* */
/* It is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file licenses/LGPLv2.1). */
/* */
/**************************************************************************/
/* ensure that the given compiler and flags support a minimal C file */
int main () { }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment