[Bf-blender-cvs] [2d429bfdf8a] master: Fix T93425: makesdna crashes during build with LTO on s390x Linux
Campbell Barton
noreply at git.blender.org
Fri Feb 4 09:50:18 CET 2022
Commit: 2d429bfdf8a4fd25891ba682618d6ba25435410b
Author: Campbell Barton
Date: Fri Feb 4 19:45:02 2022 +1100
Branches: master
https://developer.blender.org/rB2d429bfdf8a4fd25891ba682618d6ba25435410b
Fix T93425: makesdna crashes during build with LTO on s390x Linux
DNAstr was assumed to be 4-byte aligned which is not necessarily
the case for byte-arrays.
Use a compiler attribute to ensure this is the case.
Thanks to @mtasaka for investigating and providing a patch.
===================================================================
M source/blender/makesdna/intern/makesdna.c
===================================================================
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 114c0b40407..d94b95fc6f4 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -1555,8 +1555,18 @@ int main(int argc, char **argv)
base_directory = BASE_HEADER;
}
+ /* NOTE: #init_structDNA() in dna_genfile.c expects `sdna->data` is 4-bytes aligned.
+ * `DNAstr[]` buffer written by `makesdna` is used for this data, so make `DNAstr` forcefully
+ * 4-bytes aligned. */
+#ifdef __GNUC__
+# define FORCE_ALIGN_4 " __attribute__((aligned(4))) "
+#else
+# define FORCE_ALIGN_4 " "
+#endif
fprintf(file_dna, "extern const unsigned char DNAstr[];\n");
- fprintf(file_dna, "const unsigned char DNAstr[] = {\n");
+ fprintf(file_dna, "const unsigned char" FORCE_ALIGN_4 "DNAstr[] = {\n");
+#undef FORCE_ALIGN_4
+
if (make_structDNA(base_directory, file_dna, file_dna_offsets, file_dna_verify)) {
/* error */
fclose(file_dna);
More information about the Bf-blender-cvs
mailing list