aarch64: Remove output file if aarch64-gen fails
Ensures AArch64 generated opcode files are removed if generation fails, preventing stale files from causing build issues.
This patch modifies the AArch64 build process to ensure that generated opcode files (like aarch64-asm-2.c, aarch64-dis-2.c, etc.) are removed if the aarch64-gen tool fails. Previously, incomplete or erroneous output files could be left behind, potentially causing subsequent build steps to succeed with outdated or incorrect code, leading to subtle errors later in the build or link phase.
In Details
This patch adjusts the Makefile.am and Makefile.in in opcodes/ to add error handling to the generation rules for AArch64 opcode-related C and header files. Specifically, it appends || ( rm $@ && false ) to the commands that invoke aarch64-gen. This ensures that if aarch64-gen fails (returns non-zero exit status), the incomplete output file ($@) is removed, and the make command itself fails, preventing stale generated files from being used in subsequent build steps.
- aarch64-gen
- A code generator tool used within binutils to produce AArch64 assembly, disassembly, and opcode table source files based on definitions.
- Makefile
- A file that contains instructions for the
makeutility, used to automate the build process of software projects. - stale file
- A file that is outdated and no longer accurately reflects the current state of the source code or build process. In this context, it refers to an incomplete or incorrect generated file.
- Link error
- An error that occurs during the linking phase of compilation, where the linker cannot resolve references between different object files or libraries, often due to missing symbols or incompatible code.