Skip to content

Commit 361e038

Browse files
committed
fix the openmpi build on gcc14/fedora 40
- add missing construct_event_strings.py - add fix from upstream bug open-mpi/ompi#12169 which then triggers the usage of construct_event_strings.py fixes: #12 Signed-off-by: Mika Laitio <[email protected]>
1 parent 5ff2a33 commit 361e038

3 files changed

+352
-3
lines changed

patches/rocm-6.1.1/openmpi/0001-disable-prrte-docs-generation.patch

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 47da35a3624cbdb205c1d2529f12faa5a868f54d Mon Sep 17 00:00:00 2001
1+
From 03ced091cd830fe4d16ad1596228bc035e4b961c Mon Sep 17 00:00:00 2001
22
From: Mika Laitio <[email protected]>
33
Date: Wed, 24 Jan 2024 14:53:02 -0800
4-
Subject: [PATCH] disable prrte docs generation
4+
Subject: [PATCH 1/3] disable prrte docs generation
55

66
Disable prrte doc building to avoid follwing error
77
if python sphinx is not installed available:
@@ -51,5 +51,5 @@ index a623100..f98c89e 100644
5151
util \
5252
$(MCA_prte_FRAMEWORKS_SUBDIRS) \
5353
--
54-
2.43.0
54+
2.45.1
5555

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
From 9037de8d1cfb749d5bf8e8a2223de8352b9bf6b6 Mon Sep 17 00:00:00 2001
2+
From: Mika Laitio <[email protected]>
3+
Date: Wed, 29 May 2024 12:09:47 -0700
4+
Subject: [PATCH 2/3] upstream patch: Cast a few parameters when translating
5+
macros to functions
6+
7+
original patch merged to 5.0.2 version
8+
https://github.com/open-mpi/ompi/issues/12169
9+
10+
When we made the transition from macros to functions, we
11+
were forced to move things that went on the left side of
12+
an `=` sign to being addresses of params to the function
13+
call. Compilers are getting increasinly picky about matching
14+
parameter types, so cast a few that might cause trouble.
15+
16+
Signed-off-by: Ralph Castain <[email protected]>
17+
18+
Fixes following error:
19+
20+
/home/chris/rocm_sdk_builder/src_projects/openmpi/3rd-party/openpmix/include/pmix_deprecated.h:851:32: error: passing argument 2 of 'PMIx_Data_buffer_unload' from incompatible pointer type [-Wincompatible-pointer-types]
21+
851 | PMIx_Data_buffer_unload(b, &(d), &(s))
22+
| ^~~~
23+
| |
24+
| void **
25+
/home/chris/rocm_sdk_builder/src_projects/openmpi/oshmem/mca/memheap/base/memheap_base_mkey.c:451:5: note: in expansion of macro 'PMIX_DATA_BUFFER_UNLOAD'
26+
451 | PMIX_DATA_BUFFER_UNLOAD(msg, buffer, size);
27+
| ^~~~~~~~~~~~~~~~~~~~~~~
28+
/home/chris/rocm_sdk_builder/src_projects/openmpi/3rd-party/openpmix/include/pmix_deprecated.h:352:49: note: expected 'char **' but argument is of type 'void **'
29+
352 | char **bytes, size_t *sz);
30+
| ~~~~~~~^~~~~
31+
/home/chris/rocm_sdk_builder/src_projects/openmpi/oshmem/mca/memheap/base/memheap_base_mkey.c: In function 'mca_memheap_modex_recv_all':
32+
/home/chris/rocm_sdk_builder/src_projects/openmpi/3rd-party/openpmix/include/pmix_deprecated.h:851:32: error: passing argument 2 of 'PMIx_Data_buffer_unload' from incompatible pointer type [-Wincompatible-pointer-types]
33+
851 | PMIx_Data_buffer_unload(b, &(d), &(s))
34+
| ^~~~
35+
| |
36+
| void **
37+
/home/chris/rocm_sdk_builder/src_projects/openmpi/oshmem/mca/memheap/base/memheap_base_mkey.c:586:5: note: in expansion of macro 'PMIX_DATA_BUFFER_UNLOAD'
38+
586 | PMIX_DATA_BUFFER_UNLOAD(msg, send_buffer, size);
39+
| ^~~~~~~~~~~~~~~~~~~~~~~
40+
/home/chris/rocm_sdk_builder/src_projects/openmpi/3rd-party/openpmix/include/pmix_deprecated.h:352:49: note: expected 'char **' but argument is of type 'void **'
41+
352 | char **bytes, size_t *sz);
42+
43+
Signed-off-by: Mika Laitio <[email protected]>
44+
---
45+
3rd-party/openpmix/include/pmix_deprecated.h | 6 +++---
46+
1 file changed, 3 insertions(+), 3 deletions(-)
47+
48+
diff --git a/3rd-party/openpmix/include/pmix_deprecated.h b/3rd-party/openpmix/include/pmix_deprecated.h
49+
index 254dfb2..b5717ae 100644
50+
--- a/3rd-party/openpmix/include/pmix_deprecated.h
51+
+++ b/3rd-party/openpmix/include/pmix_deprecated.h
52+
@@ -508,10 +508,10 @@ PMIX_EXPORT pmix_info_t* PMIx_Info_list_get_info(void *ptr, void *prev, void **n
53+
(r) = PMIx_Argv_count(a)
54+
55+
#define PMIX_ARGV_APPEND(r, a, b) \
56+
- (r) = PMIx_Argv_append_nosize(&(a), (b))
57+
+ (r) = PMIx_Argv_append_nosize((char***)&(a), (b))
58+
59+
#define PMIX_ARGV_PREPEND(r, a, b) \
60+
- (r) = PMIx_Argv_prepend_nosize(&(a), b)
61+
+ (r) = PMIx_Argv_prepend_nosize((char***)&(a), b)
62+
63+
#define PMIX_ARGV_APPEND_UNIQUE(r, a, b) \
64+
(r) = PMIx_Argv_append_unique_nosize(a, b)
65+
@@ -848,7 +848,7 @@ PMIX_EXPORT pmix_info_t* PMIx_Info_list_get_info(void *ptr, void *prev, void **n
66+
PMIx_Data_buffer_load(b, d, s)
67+
68+
#define PMIX_DATA_BUFFER_UNLOAD(b, d, s) \
69+
- PMIx_Data_buffer_unload(b, &(d), &(s))
70+
+ PMIx_Data_buffer_unload(b, (char**)&(d), (size_t*)&(s))
71+
72+
#define PMIX_PROC_CREATE(m, n) \
73+
(m) = PMIx_Proc_create(n)
74+
--
75+
2.45.1
76+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
From 72ba0a6d531ab0cc325895bf57e5fba2edebd591 Mon Sep 17 00:00:00 2001
2+
From: Mika Laitio <[email protected]>
3+
Date: Wed, 29 May 2024 14:15:28 -0700
4+
Subject: [PATCH 3/3] added construct_event_strings.py thats missing tar.gz
5+
6+
patching of git submodules does not work well
7+
yet with the rcom sdk builder, therefore openmpi
8+
and all it's submodules has been put to single repo.
9+
10+
release openmpi-5.0.1.tar.bz2 used as a source however missed the
11+
construct_event_strings.py.
12+
13+
Another patch just added for gcc14 updating the headers
14+
seems to trigger the usage of this python file.
15+
(Earlier it compiled ok because this python script was not tried to call)
16+
17+
Signed-off-by: Mika Laitio <[email protected]>
18+
---
19+
.../contrib/construct_event_strings.py | 242 ++++++++++++++++++
20+
1 file changed, 242 insertions(+)
21+
create mode 100755 3rd-party/openpmix/contrib/construct_event_strings.py
22+
23+
diff --git a/3rd-party/openpmix/contrib/construct_event_strings.py b/3rd-party/openpmix/contrib/construct_event_strings.py
24+
new file mode 100755
25+
index 0000000..52f242f
26+
--- /dev/null
27+
+++ b/3rd-party/openpmix/contrib/construct_event_strings.py
28+
@@ -0,0 +1,242 @@
29+
+#
30+
+# Copyright (c) 2020 Intel, Inc. All rights reserved.
31+
+# Copyright (c) 2020-2022 Cisco Systems, Inc. All rights reserved
32+
+# Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
33+
+# Copyright (c) 2022 Triad National Security, LLC. All rights reserved.
34+
+# $COPYRIGHT$
35+
+#
36+
+# Construct a dictionary for translating attributes to/from
37+
+# their defined name and their string representation - used
38+
+# by tools to interpret user input
39+
+#
40+
+
41+
+from __future__ import print_function
42+
+import os
43+
+import os.path
44+
+import sys
45+
+from optparse import OptionParser, OptionGroup
46+
+
47+
+index = 0
48+
+
49+
+
50+
+def harvest_constants(options, path, constants):
51+
+ global index
52+
+ # open the file
53+
+ try:
54+
+ inputfile = open(path, "r")
55+
+ except Exception as e:
56+
+ print("File {path} could not be opened: {e}"
57+
+ .format(path=path, e=e))
58+
+ return 1
59+
+
60+
+ # read the file - these files aren't too large
61+
+ # so ingest the whole thing at one gulp
62+
+ try:
63+
+ lines = inputfile.readlines()
64+
+ except Exception as e:
65+
+ print("Error reading file {path}: {e}"
66+
+ .format(path=path, e=e))
67+
+ inputfile.close()
68+
+ return 1
69+
+
70+
+ inputfile.close() # we read everything, so done with the file
71+
+
72+
+ firstline = True
73+
+
74+
+ # find the start of the event codes
75+
+ n = 0
76+
+ found = False
77+
+ while n < len(lines):
78+
+ if "PMIX ERROR CONSTANTS" in lines[n]:
79+
+ found = True
80+
+ n = n + 1
81+
+ break;
82+
+ n = n + 1
83+
+ # error out if not found
84+
+ if not found:
85+
+ print("START OF EVENT CODES NOT FOUND")
86+
+ return 1
87+
+
88+
+ # loop over the lines
89+
+ while n < len(lines):
90+
+ line = lines[n]
91+
+ # remove white space at front and back
92+
+ myline = line.strip()
93+
+ # remove comment lines
94+
+ if "/*" in myline or "*/" in myline or myline.startswith("*"):
95+
+ n = n + 1
96+
+ continue
97+
+ # if we have found the end of the event codes, we are done
98+
+ if "PMIX_EXTERNAL_ERR_BASE" in myline or "PMIX_ERR_SYS_BASE" in myline or "PMIX_INTERNAL_ERR_DONE" in myline:
99+
+ return 0
100+
+ # skip a well-known macro
101+
+ if "PMIX_SYSTEM_EVENT" in myline:
102+
+ n = n + 2
103+
+ continue
104+
+ # if the line starts with #define, then we want it
105+
+ if not myline.startswith("#define"):
106+
+ n = n + 1
107+
+ continue
108+
+
109+
+ value = myline[8:]
110+
+ tokens = value.split()
111+
+ if not firstline:
112+
+ constants.write(",\n\n")
113+
+ firstline = False
114+
+ constants.write(" {.index = " + str(index) + ", .name = \"" + tokens[0] + "\", .code = " + str(tokens[1]) + "}")
115+
+ index = index + 1
116+
+ n = n + 1
117+
+
118+
+ return 0
119+
+
120+
+
121+
+def _write_header(options, base_path, num_elements):
122+
+ contents = '''/*
123+
+ * This file is autogenerated by construct_event_strings.py.
124+
+ * Do not edit this file by hand.
125+
+ */
126+
+
127+
+#include "src/include/pmix_config.h"
128+
+#include "src/include/pmix_globals.h"
129+
+#include "include/pmix_common.h"
130+
+
131+
+#ifndef PMIX_EVENT_STRINGS_H
132+
+#define PMIX_EVENT_STRINGS_H
133+
+
134+
+BEGIN_C_DECLS
135+
+
136+
+PMIX_EXPORT extern const pmix_event_string_t pmix_event_strings[{ne}];
137+
+
138+
+#define PMIX_EVENT_INDEX_BOUNDARY {nem1}
139+
+
140+
+END_C_DECLS
141+
+
142+
+#endif\n
143+
+'''.format(ne=num_elements, nem1=num_elements - 1)
144+
+
145+
+ if options.dryrun:
146+
+ constants = sys.stdout
147+
+ outpath = None
148+
+ else:
149+
+ outpath = os.path.join(base_path, "pmix_event_strings.h")
150+
+ try:
151+
+ constants = open(outpath, "w+")
152+
+ except Exception as e:
153+
+ print("{outpath} CANNOT BE OPENED - EVENT STRINGS COULD NOT BE CONSTRUCTED: {e}"
154+
+ .format(outpath=outpath, e=e))
155+
+ return 1
156+
+ constants.write(contents)
157+
+ constants.close()
158+
+ return 0
159+
+
160+
+
161+
+def main():
162+
+ parser = OptionParser("usage: %prog [options]")
163+
+ debugGroup = OptionGroup(parser, "Debug Options")
164+
+ debugGroup.add_option("--dryrun",
165+
+ action="store_true", dest="dryrun", default=False,
166+
+ help="Show output to screen")
167+
+ parser.add_option_group(debugGroup)
168+
+
169+
+ (options, args) = parser.parse_args()
170+
+
171+
+ # Find the top-level PMIx source tree dir.
172+
+ # Start with the location of this script, which we know is in
173+
+ # $top_srcdir/contrib.
174+
+ top_src_dir = os.path.dirname(sys.argv[0])
175+
+ top_src_dir = os.path.join(top_src_dir, "..")
176+
+ top_src_dir = os.path.abspath(top_src_dir)
177+
+
178+
+ # Sanity check
179+
+ checkfile = os.path.join(top_src_dir, "VERSION")
180+
+ if not os.path.exists(checkfile):
181+
+ print("ERROR: Could not find top source directory for Open PMIx")
182+
+ return 1
183+
+
184+
+ source_include_dir = os.path.join(top_src_dir, "include")
185+
+ util_include_dir = os.path.join(top_src_dir, "src", "util")
186+
+
187+
+ # This script is invoked from src/include/Makefile.am, and
188+
+ # therefore the cwd will be $(builddir)/src/include. Verify this
189+
+ # by checking for a file that we know should be in there.
190+
+ build_src_include_dir = os.getcwd()
191+
+ checkfile = os.path.join(build_src_include_dir, "pmix_config.h")
192+
+ if not os.path.exists(checkfile):
193+
+ print("ERROR: Could not find build directory for Open PMIx")
194+
+ return 1
195+
+
196+
+ if options.dryrun:
197+
+ constants = sys.stdout
198+
+ outpath = None
199+
+ else:
200+
+ outpath = os.path.join(build_src_include_dir, "pmix_event_strings.c")
201+
+ try:
202+
+ constants = open(outpath, "w+")
203+
+ except Exception as e:
204+
+ print("{outpath} CANNOT BE OPENED - EVENT STRINGS COULD NOT BE CONSTRUCTED: {e}"
205+
+ .format(outpath=outpath, e=e))
206+
+ return 1
207+
+
208+
+ # write the source file
209+
+ constants.write("""/*
210+
+ * This file is autogenerated by construct_event_strings.py.
211+
+ * Do not edit this file by hand.
212+
+ */
213+
+
214+
+#include "src/include/pmix_event_strings.h"
215+
+
216+
+const pmix_event_string_t pmix_event_strings[] = {
217+
+""")
218+
+
219+
+ # scan across the header files in the src directory
220+
+ # looking for events
221+
+
222+
+ # pmix_common.h.in is in the src tree
223+
+ rc = harvest_constants(options,
224+
+ os.path.join(source_include_dir, "pmix_common.h.in"),
225+
+ constants)
226+
+ if 0 != rc:
227+
+ constants.close()
228+
+ if outpath:
229+
+ os.remove(outpath)
230+
+ print("HARVEST PMIX_COMMON FAILED - EVENT STRINGS COULD NOT BE CONSTRUCTED")
231+
+ return 1
232+
+ constants.write(",\n\n")
233+
+
234+
+ # pmix_deprecated.h is in the source tree
235+
+ rc = harvest_constants(options,
236+
+ os.path.join(source_include_dir, "pmix_deprecated.h"),
237+
+ constants)
238+
+ if 0 != rc:
239+
+ constants.close()
240+
+ if outpath:
241+
+ os.remove(outpath)
242+
+ print("HARVEST PMIX_DEPRECATED FAILED - EVENT STRINGS COULD NOT BE CONSTRUCTED")
243+
+ return 1
244+
+ constants.write(",\n\n")
245+
+
246+
+ # pmix_error.h is in the source tree
247+
+ rc = harvest_constants(options,
248+
+ os.path.join(util_include_dir, "pmix_error.h"),
249+
+ constants)
250+
+ if 0 != rc:
251+
+ constants.close()
252+
+ if outpath:
253+
+ os.remove(outpath)
254+
+ print("HARVEST PMIX_ERROR FAILED - EVENT STRINGS COULD NOT BE CONSTRUCTED")
255+
+ return 1
256+
+
257+
+ # mark the end of the array
258+
+ constants.write(""",\n
259+
+ {.index = UINT32_MAX, .name = "", .code = -1}
260+
+};
261+
+""")
262+
+ constants.write("\n")
263+
+ constants.close()
264+
+
265+
+ # write the header
266+
+ return _write_header(options, build_src_include_dir, index + 1)
267+
+
268+
+
269+
+if __name__ == '__main__':
270+
+ exit(main())
271+
--
272+
2.45.1
273+

0 commit comments

Comments
 (0)