Skip to content

Commit

Permalink
Make use of GOAMD64
Browse files Browse the repository at this point in the history
Add export for GOAMD64 and modify where needed in order to support
building optimized binaries using golang.

Signed-off-by: William Douglas <[email protected]>
  • Loading branch information
bryteise committed Feb 5, 2024
1 parent 25ad860 commit 213bb01
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions autospec/specfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ def write_make_install(self):

self.write_license_files()

self._write_strip("export GOAMD64=v2")
if self.config.config_opts['32bit']:
self._write_strip("pushd ../build32/" + self.config.subdir)
self._write_strip("%make_install32 {} {}".format(self.config.extra_make_install,
Expand All @@ -729,28 +730,33 @@ def write_make_install(self):
self._write_strip("popd")

if self.config.config_opts['use_avx2']:
self._write_strip("GOAMD64=v3")
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
self._write_strip("%s_v3 %s\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")

if self.config.config_opts['use_avx512']:
self._write_strip("GOAMD64=v4")
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
self._write_strip("%s_v4 %s\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")

if self.config.config_opts['use_apx']:
self._write_strip("GOAMD64=v3")
self._write_strip("pushd ../buildapx/" + self.config.subdir)
self._write_strip("%s_va %s\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")

if self.config.config_opts['openmpi']:
self._write_strip("GOAMD64=v3")
self._write_strip("pushd ../build-openmpi/" + self.config.subdir)
self.write_install_openmpi()
self._write_strip("popd")

if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)

self._write_strip("GOAMD64=v2")
self._write_strip("%s %s\n" % (self.config.install_macro, self.config.extra_make_install))

if self.config.subdir:
Expand Down Expand Up @@ -879,6 +885,8 @@ def write_cmake_install(self):

self.write_license_files()

self._write_strip("export GOAMD64=v2")

if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)

Expand All @@ -902,25 +910,30 @@ def write_cmake_install(self):
self._write_strip("popd")

if self.config.config_opts['use_avx2']:
self._write_strip("GOAMD64=v3")
self._write_strip("pushd clr-build-avx2")
self._write_strip("%s_v3 %s || :\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")

if self.config.config_opts['use_avx512']:
self._write_strip("GOAMD64=v4")
self._write_strip("pushd clr-build-avx512")
self._write_strip("%s_v4 %s || :\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")

if self.config.config_opts['use_apx']:
self._write_strip("GOAMD64=v3")
self._write_strip("pushd clr-build-apx")
self._write_strip("%s_va %s || :\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")

if self.config.config_opts['openmpi']:
self._write_strip("GOAMD64=v3")
self._write_strip("pushd clr-build-openmpi")
self.write_install_openmpi()
self._write_strip("popd")

self._write_strip("GOAMD64=v2")
self._write_strip("pushd clr-build")
self._write_strip("%s %s\n" % (self.config.install_macro, self.config.extra_make_install))
self._write_strip("popd")
Expand Down Expand Up @@ -1003,6 +1016,7 @@ def write_configure_pattern(self):
self.write_profile_payload("configure")
if self.config.subdir:
self._write_strip("pushd {}".format(self.config.subdir))
self._write_strip("export GOAMD64=v2")
self._write_strip("{0}%configure {1} {2} {3}"
.format(self.get_profile_use_flags(),
self.config.disable_static,
Expand Down Expand Up @@ -1031,6 +1045,7 @@ def write_configure_pattern(self):
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1047,6 +1062,7 @@ def write_configure_pattern(self):
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v4")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
Expand All @@ -1063,6 +1079,7 @@ def write_configure_pattern(self):
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("pushd ../buildapx/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip('CC="gcc-14"')
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {APX_CFLAGS} {APX_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1081,6 +1098,7 @@ def write_configure_pattern(self):
self._write_strip(". /usr/share/defaults/etc/profile.d/modules.sh")
self._write_strip("module load openmpi")
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1105,6 +1123,7 @@ def write_configure_ac_pattern(self):
self.write_profile_payload("configure_ac")
if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)
self._write_strip("export GOAMD64=v2")
self._write_strip("{0}%reconfigure {1} {2} {3}"
.format(self.get_profile_use_flags(),
self.config.disable_static,
Expand Down Expand Up @@ -1132,6 +1151,7 @@ def write_configure_ac_pattern(self):
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1148,6 +1168,7 @@ def write_configure_ac_pattern(self):
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v4")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
Expand All @@ -1164,6 +1185,7 @@ def write_configure_ac_pattern(self):
self._write_strip("unset PKG_CONFIG_PATH")
self._write_strip("pushd ../buildapx/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip('CC="gcc-14"')
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {APX_CFLAGS} {APX_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1189,6 +1211,7 @@ def write_make_pattern(self):
self.write_profile_payload("make")
if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)
self._write_strip("export GOAMD64=v2")
self.write_make_line()
if self.config.subdir:
self._write_strip("popd")
Expand All @@ -1201,6 +1224,7 @@ def write_make_pattern(self):
if self.config.config_opts['use_avx2']:
self._write_strip("pushd ../buildavx2" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1211,6 +1235,7 @@ def write_make_pattern(self):
if self.config.config_opts['use_avx512']:
self._write_strip("pushd ../buildavx512" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v4")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
Expand All @@ -1221,6 +1246,7 @@ def write_make_pattern(self):
if self.config.config_opts['use_apx'] and not self.config.config_opts['use_clang']:
self._write_strip("pushd ../buildapx" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip('CC=gcc-14')
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {APX_CFLAGS} {APX_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1240,6 +1266,7 @@ def write_autogen_pattern(self):
self.write_lang_c(export_epoch=True)
self.write_variables()
self.write_profile_payload("autogen")
self._write_strip("export GOAMD64=v2")
self._write_strip("{0}%autogen {1} {2} {3}"
.format(self.get_profile_use_flags(),
self.config.disable_static,
Expand All @@ -1265,6 +1292,7 @@ def write_autogen_pattern(self):
if self.config.config_opts['use_avx2']:
self._write_strip("pushd ../buildavx2/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1280,6 +1308,7 @@ def write_autogen_pattern(self):
if self.config.config_opts['use_avx512']:
self._write_strip("pushd ../buildavx512/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v4")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
Expand All @@ -1295,6 +1324,7 @@ def write_autogen_pattern(self):
if self.config.config_opts['use_apx'] and not self.config.config_opts['use_clang']:
self._write_strip("pushd ../buildapx/" + self.config.subdir)
self.write_build_prepend()
self._write_strip("GOAMD64=v3")
self._write_strip('CC=gcc-14')
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {APX_CFLAGS} {APX_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand Down Expand Up @@ -1588,6 +1618,7 @@ def write_cmake_pattern(self):
self._write_strip("mkdir -p clr-build")
self._write_strip("pushd clr-build")
self.write_variables()
self._write_strip("export GOAMD64=v2")
self._write_strip("%cmake {} {}".format(self.config.cmake_srcdir, self.extra_cmake))

self.write_profile_payload("cmake")
Expand All @@ -1600,6 +1631,7 @@ def write_cmake_pattern(self):
self._write_strip("pushd clr-build-avx2")
self.write_build_prepend()
self.write_variables()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand All @@ -1613,6 +1645,7 @@ def write_cmake_pattern(self):
self._write_strip("pushd clr-build-avx512")
self.write_build_prepend()
self.write_variables()
self._write_strip("GOAMD64=v4")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX512_CFLAGS} {AVX512_LFLAGS} "')
Expand All @@ -1626,6 +1659,7 @@ def write_cmake_pattern(self):
self._write_strip("pushd clr-build-apx")
self.write_build_prepend()
self.write_variables()
self._write_strip("GOAMD64=v3")
self._write_strip('CC=gcc-14')
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {APX_CFLAGS} {APX_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand Down Expand Up @@ -1656,6 +1690,7 @@ def write_cmake_pattern(self):
self._write_strip("module load openmpi")
self.write_build_prepend()
self.write_variables()
self._write_strip("GOAMD64=v3")
self._write_strip(f'CFLAGS="$CLEAR_INTERMEDIATE_CFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'CXXFLAGS="$CLEAR_INTERMEDIATE_CXXFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
self._write_strip(f'FFLAGS="$CLEAR_INTERMEDIATE_FFLAGS {AVX2_CFLAGS} {AVX2_LFLAGS} "')
Expand Down Expand Up @@ -1767,11 +1802,13 @@ def write_meson_pattern(self):
self.write_variables()
if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)
self._write_strip("export GOAMD64=v2")
self._write_strip('meson --libdir=lib64 --prefix=/usr --buildtype=plain {0} {1} builddir'
.format(self.config.extra_configure,
self.config.extra_configure64))
self._write_strip("ninja -v -C builddir")
if self.config.config_opts['use_avx2']:
self._write_strip("GOAMD64=v3")
if self.config.config_opts['pgo'] and self.config.profile_payload != "":
self._write_strip(f'CFLAGS="$CFLAGS_GENERATE {AVX2_CFLAGS} {AVX2_LFLAGS} " CXXFLAGS="$CXXFLAGS_GENERATE '
f'{AVX2_CFLAGS} {AVX2_LFLAGS} " LDFLAGS="$LDFLAGS_GENERATE {AVX2_LCFLAGS} " '
Expand All @@ -1794,6 +1831,7 @@ def write_meson_pattern(self):
'{1} builddiravx2'.format(self.config.extra_configure, self.config.extra_configure64))
self._write_strip('ninja -v -C builddiravx2')
if self.config.config_opts['use_avx512']:
self._write_strip("GOAMD64=v4")
if self.config.config_opts['pgo'] and self.config.profile_payload != "":
self._write_strip(f'CFLAGS="$CFLAGS_GENERATE {AVX512_CFLAGS} {AVX512_LFLAGS} " CXXFLAGS="$CXXFLAGS_GENERATE '
f'{AVX512_CFLAGS} {AVX512_LFLAGS} " LDFLAGS="$LDFLAGS_GENERATE {AVX512_LCFLAGS} " '
Expand All @@ -1816,6 +1854,7 @@ def write_meson_pattern(self):
'{1} builddiravx512'.format(self.config.extra_configure, self.config.extra_configure64))
self._write_strip('ninja -v -C builddiravx512')
if self.config.config_opts['use_apx'] and not self.config.config_opts['use_clang']:
self._write_strip("GOAMD64=v3")
self._write_strip('CC=gcc-14')
if self.config.config_opts['pgo'] and self.config.profile_payload != "":
self._write_strip(f'CFLAGS="$CFLAGS_GENERATE {APX_CFLAGS} {APX_LFLAGS} "'
Expand Down Expand Up @@ -1859,6 +1898,7 @@ def write_meson_pattern(self):
self._write_strip("%install")
self.write_variables()
self.write_install_prepend()
self._write_strip("export GOAMD64=v2")
self.write_license_files()
if self.config.config_opts['32bit']:
self._write_strip('pushd ../build32/' + self.config.subdir)
Expand All @@ -1879,13 +1919,17 @@ def write_meson_pattern(self):
if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)
if self.config.config_opts['use_avx2']:
self._write_strip("GOAMD64=v3")
self._write_strip('DESTDIR=%{buildroot}-v3 ninja -C builddiravx2 install')
if self.config.config_opts['use_avx512']:
self._write_strip("GOAMD64=v4")
self._write_strip('DESTDIR=%{buildroot}-v4 ninja -C builddiravx512 install')
if self.config.config_opts['use_apx'] and not self.config.config_opts['use_clang']:
self._write_strip("GOAMD64=v3")
self._write_strip('CC=gcc-14')
self._write_strip('DESTDIR=%{buildroot}-va ninja -C builddirapx install')

self._write_strip("GOAMD64=v2")
self._write_strip("DESTDIR=%{buildroot} ninja -C builddir install")
if self.config.subdir:
self._write_strip("popd")
Expand Down

0 comments on commit 213bb01

Please sign in to comment.