from pathlib import Path # This recipe bootstraps an initial compiler that is used # for the cross-toolchain to compile the CRT before the # real final compiler. class Recipe(recipe.Recipe): name = 'gcc-bootstrap' version = '14.2.0' stype = SourceType.CUSTOM licenses = [License.GPLv3Plus] override_libtool = False configure_options = '--disable-maintainer-mode ' \ '--with-host-libstdcxx=\'-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm\' ' \ '--disable-shared ' \ '--disable-libgomp ' \ '--disable-libquadmath ' \ '--disable-libquadmath-support ' \ '--disable-libmudflap ' \ '--disable-libmpx ' \ '--disable-libssp ' \ '--disable-nls ' \ '--enable-threads=no ' \ '--enable-__cxa_atexit ' \ '--enable-lto ' \ '--enable-languages=c,c++,lto ' \ '--enable-multiarch ' \ '' requires_non_src_build = True use_system_libs = True add_host_build_target = False deps = ['gcc-sources', 'mingw-w64-headers', 'gmp', 'mpfr', 'mpc', 'isl'] def prepare(self): if self.config.target_arch == Architecture.X86: raise InvalidRecipeError(self) self._target = 'x86_64-w64-mingw32' self.sysroot = f'{self.config.prefix}/{self._target}/sysroot' self.configure_options += f' --with-sysroot={self.sysroot} ' self.configure_options += f' --with-local-prefix={self.sysroot} ' self.configure_options += f' --with-native-system-header-dir=/usr/{self._target}/include ' self.configure_options += ' --target=%s' % self._target if self.config.target_platform == Platform.WINDOWS: self.configure_options += ' --host=%s' % self._target self.config_src_dir = os.path.join(self.config.sources, f'gcc-sources-{self.version}') self.build_dir = os.path.join(self.config_src_dir, 'gcc_build_core') self.make_dir = self.build_dir self.make += ['all-gcc'] self.make_install = ['install-strip-gcc' if i == 'install' else i for i in self.make_install] async def configure(self): # https://github.com/msys2/MINGW-packages/commit/54101537025a9a3a381a1e292fb9bc967e374bd2 header = os.path.join(self.config_src_dir, 'gcc/config/i386/mingw32.h') shell.replace(header, {'/mingw': f'/usr/{self._target}'}) Path(self.make_dir).mkdir(exist_ok=True) await super(Recipe, self).configure()