When no .file directive is given, the toolchain records the filename
of the .o file, which is sometimes random, making generated objects
non-deterministic.
We use Location.input_name for adding .file directives to assembly
files. Note: when the file is preprocessed, this reference holds the
name of the temporary file. Hence, files compiled with -pp are still
not deterministic.
Bug-Debian: https://bugs.debian.org/795784
Bug-Debian: https://bugs.debian.org/796336
Gbp-Pq: Name 0010-Add-a-.file-directive-to-generated-.s-files.patch
let begin_assembly() =
reset_debug_info(); (* PR#5603 *)
float_constants := [];
+ ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
if !Clflags.dlcode then begin
(* from amd64.S; could emit these constants on demand *)
if macosx then
let begin_assembly() =
reset_debug_info();
+ ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
` .syntax unified\n`;
begin match !arch with
| ARMv4 -> ` .arch armv4t\n`
let begin_assembly() =
reset_debug_info();
+ ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
` .data\n`;
` .globl {emit_symbol lbl_begin}\n`;
let begin_assembly() =
reset_debug_info(); (* PR#5603 *)
float_constants := [];
+ ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
` .data\n`;
` .globl {emit_symbol lbl_begin}\n`;
let begin_assembly() =
defined_functions := StringSet.empty;
external_functions := StringSet.empty;
+ ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
(* Emit the beginning of the segments *)
let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
emit_string data_space;
(* Beginning / end of an assembly file *)
let begin_assembly() =
+ ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
` .data\n`;
` .global {emit_symbol lbl_begin}\n`;