aboutsummaryrefslogtreecommitdiff
path: root/rakelib/gcc.rake
diff options
context:
space:
mode:
Diffstat (limited to 'rakelib/gcc.rake')
-rw-r--r--rakelib/gcc.rake64
1 files changed, 47 insertions, 17 deletions
diff --git a/rakelib/gcc.rake b/rakelib/gcc.rake
index 3f36ce9..7e00d1b 100644
--- a/rakelib/gcc.rake
+++ b/rakelib/gcc.rake
@@ -58,32 +58,57 @@ def download_and_pipe(url, target, command)
end
end
+def link_frontend(source, destination)
+ File.symlink Pathname.new(source).relative_path_from(destination), (destination + File.basename(source))
+end
+
namespace :gcc do
# Dependencies.
GCC_VERSION = "15.3.0"
HOST_GCC = 'build/host/gcc'
- HOST_INSTALL = 'build/host/install'
+ GCC_TREE = Pathname.new "build/tools/gcc-#{GCC_VERSION}"
GCC_PATCH = 'https://raw.githubusercontent.com/Homebrew/homebrew-core/refs/heads/main/Patches/gcc/gcc-15.3.0.diff'
directory HOST_GCC
- directory HOST_INSTALL
+ directory 'build/host/install'
directory 'build/tools'
- desc 'Download and configure the bootstrap compiler'
- task configure: ['build/tools', HOST_GCC, HOST_INSTALL] do
+ desc 'Download the bootstrap compiler and its prerequisites'
+ task download: 'build/tools' do
url = URI.parse "https://gcc.gnu.org/pub/gcc/releases/gcc-#{GCC_VERSION}/gcc-#{GCC_VERSION}.tar.xz"
- build_target = find_build_target
- source_directory = Pathname.new "build/tools/gcc-#{GCC_VERSION}"
- frontend_link = source_directory + 'gcc'
- download_and_pipe url, source_directory.dirname, ['tar', '-Jxv']
- download_and_pipe URI.parse(GCC_PATCH), source_directory, ['patch', '-p1']
+ download_and_pipe url, GCC_TREE.dirname, ['tar', '-Jxv']
+ download_and_pipe URI.parse(GCC_PATCH), GCC_TREE, ['patch', '-p1']
+
+ sh 'contrib/download_prerequisites', chdir: GCC_TREE.to_path
+ end
+
+ desc 'Link the frontend into the GCC source tree'
+ task :link do
+ source_destination = GCC_TREE + 'gcc/elna'
+ test_destination = GCC_TREE + 'gcc/testsuite/elna.dg'
- sh 'contrib/download_prerequisites', chdir: source_directory.to_path
- File.symlink Pathname.new('.').relative_path_from(frontend_link), (frontend_link + 'elna')
+ rm_rf [source_destination, test_destination]
+ mkdir_p [source_destination, test_destination]
+
+ FileList['boot', 'include', 'COPYING3', 'README.md', 'gcc/gcc', 'gcc/*.in', 'gcc/lang*'].each do |file|
+ link_frontend file, source_destination
+ end
+ FileList['testsuite/*', 'gcc/dg.exp', 'README.md'].each do |file|
+ link_frontend file, test_destination
+ end
+ destination = GCC_TREE + 'gcc/testsuite/lib'
+ FileList['gcc/testlib/*'].each do |file|
+ rm_f (destination + File.basename(file))
+ link_frontend file, destination
+ end
+ end
+ desc 'Configure the bootstrap compiler'
+ task configure: [HOST_GCC, 'build/host/install'] do |t|
+ build_target = find_build_target
configure_options = [
- "--prefix=#{File.realpath HOST_INSTALL}",
+ "--prefix=#{File.realpath t.prerequisites.last}",
'--enable-languages=c,c++,jit,elna',
'--disable-bootstrap',
'--disable-multilib',
@@ -93,13 +118,13 @@ namespace :gcc do
"--build=#{build_target}",
"--host=#{build_target}"
]
- if File.symlink? '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
- configure_options << '--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
- end
+ mac_os_sdk = '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
+ configure_options << "--with-sysroot=#{mac_os_sdk}" if File.symlink? mac_os_sdk
+
env = ENV.slice 'CC', 'CXX'
env['CFLAGS'] = env['CXXFLAGS'] = '-O0 -g -fPIC -I/opt/homebrew/opt/flex/include'
- configure = source_directory.relative_path_from(HOST_GCC) + 'configure'
+ configure = GCC_TREE.relative_path_from(HOST_GCC) + 'configure'
sh env, configure.to_path, *configure_options, chdir: HOST_GCC
end
@@ -108,7 +133,12 @@ namespace :gcc do
sh 'make', '-j', Etc.nprocessors.to_s, chdir: HOST_GCC
sh 'make', 'install', chdir: HOST_GCC
end
+
+ desc 'Run tests'
+ task :check do
+ sh 'make', 'check-elna', chdir: File.join(HOST_GCC, 'gcc')
+ end
end
desc 'Build the bootstrap compiler'
-task gcc: %w[gcc:configure gcc:make]
+task gcc: %w[gcc:download gcc:link gcc:configure gcc:make]