diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-03 22:41:48 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-03 22:41:48 +0200 |
| commit | e068da3028c1ae30741d2d1ceaca691b71830bfe (patch) | |
| tree | 9ef6fb075bb0c02d7124f9a28b7983fc8cf40203 | |
| parent | b6b68b25043fc4008af6c7bfb4573593a858a9de (diff) | |
| download | elna-e068da3028c1ae30741d2d1ceaca691b71830bfe.tar.gz | |
| -rw-r--r-- | README.md | 5 | ||||
| -rw-r--r-- | config-lang.in | 21 | ||||
| -rw-r--r-- | gcc/Make-lang.in | 5 | ||||
| -rw-r--r-- | gcc/config-lang.in | 2 | ||||
| -rw-r--r-- | gcc/dg.exp | 29 | ||||
| -rw-r--r-- | gcc/gcc/elna-builtins.cc (renamed from gcc/elna-builtins.cc) | 0 | ||||
| -rw-r--r-- | gcc/gcc/elna-diagnostic.cc (renamed from gcc/elna-diagnostic.cc) | 0 | ||||
| -rw-r--r-- | gcc/gcc/elna-generic.cc (renamed from gcc/elna-generic.cc) | 0 | ||||
| -rw-r--r-- | gcc/gcc/elna-spec.cc (renamed from gcc/elna-spec.cc) | 0 | ||||
| -rw-r--r-- | gcc/gcc/elna-tree.cc (renamed from gcc/elna-tree.cc) | 0 | ||||
| -rw-r--r-- | gcc/gcc/elna1.cc (renamed from gcc/elna1.cc) | 0 | ||||
| -rw-r--r-- | gcc/gcc/gelna.texi (renamed from gcc/gelna.texi) | 0 | ||||
| -rw-r--r-- | gcc/testlib/elna-dg.exp | 66 | ||||
| -rw-r--r-- | gcc/testlib/elna.exp | 155 | ||||
| -rw-r--r-- | rakelib/gcc.rake | 64 | ||||
| -rw-r--r-- | testsuite/compilable/empty_proc.elna | 4 |
16 files changed, 307 insertions, 44 deletions
@@ -16,11 +16,6 @@ in the `boot/` directory. The frontend requires GCC 15.3.0 (not tested with other versions). -Download the GCC source. Copy the contents of this repository into `gcc/elna` -inside GCC. Finally build GCC enabling the frontend with -`--enable-languages=c,c++,elna`. After the installation the compiler can be -invoked with `$prefix/bin/gelna`. - There is also a `Rakefile` that downloads, builds and installs GCC into the `./build/` subdirectory. The `Rakefile` assumes that ruby and rake, as well as all GCC dependencies are already available in the system. It works under Linux diff --git a/config-lang.in b/config-lang.in deleted file mode 100644 index 1bc1697..0000000 --- a/config-lang.in +++ /dev/null @@ -1,21 +0,0 @@ -# Top level configure fragment for gcc Elna frontend. -# Copyright (C) 2025 Free Software Foundation, Inc. - -# GCC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. - -# GCC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with GCC; see the file COPYING3. If not see -# <http://www.gnu.org/licenses/>. - -language="elna" -gcc_subdir="elna/gcc" - -. ${srcdir}/elna/gcc/config-lang.in diff --git a/gcc/Make-lang.in b/gcc/Make-lang.in index efc7687..cb57798 100644 --- a/gcc/Make-lang.in +++ b/gcc/Make-lang.in @@ -66,6 +66,11 @@ elna.all.cross: gelna-cross$(exeext) elna.start.encap: gelna$(exeext) elna.rest.encap: +lang_checks += check-elna +lang_checks_parallelized += check-elna +# For description see the check_$lang_parallelize comment in gcc/Makefile.in. +check_elna_parallelize = 10 + # No elna-specific selftests. selftest-elna: diff --git a/gcc/config-lang.in b/gcc/config-lang.in index 0cbbe1f..a003be7 100644 --- a/gcc/config-lang.in +++ b/gcc/config-lang.in @@ -23,7 +23,7 @@ # compilers - value to add to $(COMPILERS) language="elna" -gcc_subdir="elna/gcc" +# gcc_subdir="elna/gcc" compilers="elna1\$(exeext)" diff --git a/gcc/dg.exp b/gcc/dg.exp new file mode 100644 index 0000000..ce424d9 --- /dev/null +++ b/gcc/dg.exp @@ -0,0 +1,29 @@ +# Copyright (C) 2004-2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib elna-dg.exp + +# Initialize dg. +dg-init + +# Main loop. +elna-dg-runtest [lsort [find $srcdir/$subdir *.elna]] "" "" + +# All done. +dg-finish diff --git a/gcc/elna-builtins.cc b/gcc/gcc/elna-builtins.cc index 7c97027..7c97027 100644 --- a/gcc/elna-builtins.cc +++ b/gcc/gcc/elna-builtins.cc diff --git a/gcc/elna-diagnostic.cc b/gcc/gcc/elna-diagnostic.cc index fa32788..fa32788 100644 --- a/gcc/elna-diagnostic.cc +++ b/gcc/gcc/elna-diagnostic.cc diff --git a/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 66bd9a2..66bd9a2 100644 --- a/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc diff --git a/gcc/elna-spec.cc b/gcc/gcc/elna-spec.cc index 5d1ace1..5d1ace1 100644 --- a/gcc/elna-spec.cc +++ b/gcc/gcc/elna-spec.cc diff --git a/gcc/elna-tree.cc b/gcc/gcc/elna-tree.cc index de7f6b0..de7f6b0 100644 --- a/gcc/elna-tree.cc +++ b/gcc/gcc/elna-tree.cc diff --git a/gcc/elna1.cc b/gcc/gcc/elna1.cc index 0333f70..0333f70 100644 --- a/gcc/elna1.cc +++ b/gcc/gcc/elna1.cc diff --git a/gcc/gelna.texi b/gcc/gcc/gelna.texi index e4bc6ce..e4bc6ce 100644 --- a/gcc/gelna.texi +++ b/gcc/gcc/gelna.texi diff --git a/gcc/testlib/elna-dg.exp b/gcc/testlib/elna-dg.exp new file mode 100644 index 0000000..baefe36 --- /dev/null +++ b/gcc/testlib/elna-dg.exp @@ -0,0 +1,66 @@ +# Copyright (C) 2004-2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +load_lib gcc-dg.exp + +# Define elna callbacks for dg.exp. + +proc elna-dg-test { prog do_what extra_tool_flags } { + set result \ + [gcc-dg-test-1 elna_target_compile $prog $do_what $extra_tool_flags] + + set comp_output [lindex $result 0] + set output_file [lindex $result 1] + + return [list $comp_output $output_file] +} + +proc elna-dg-prune { system text } { + return [gcc-dg-prune $system $text] +} + +# Utility routines. + +# +# Modified dg-runtest that can cycle through a list of optimization options +# as c-torture does. +# + +proc elna-dg-runtest { testcases flags default-extra-flags } { + global runtests + global dg-do-what-default + global tool + + foreach testcase $testcases { + # If we're only testing specific files and this isn't one of them, skip it. + if {![runtest_file_p $runtests $testcase]} { + continue + } + # Check the test directory to detect the test type and set the expectation. + set type [file tail [file dirname $testcase]] + switch $type { + compilable { + set dg-do-what-default "compile" + } + default { + ${tool}_fail $testcase "Unknown test type \"$type\"" + return 0 + } + } + verbose "Testing $type/[file tail $testcase]" + dg-test $testcase $flags ${default-extra-flags} + } +} diff --git a/gcc/testlib/elna.exp b/gcc/testlib/elna.exp new file mode 100644 index 0000000..628a79f --- /dev/null +++ b/gcc/testlib/elna.exp @@ -0,0 +1,155 @@ +# Copyright (C) 2003-2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# +# elna support library routines +# +load_lib prune.exp +load_lib gcc-defs.exp +load_lib timeout.exp +load_lib target-libpath.exp + +# +# ELNA_UNDER_TEST is the compiler under test. +# + + +set gpp_compile_options "" + + +# +# elna_version -- extract and print the version number of the compiler +# + +proc elna_version { } { + global ELNA_UNDER_TEST + + elna_init + + # ignore any arguments after the command + set compiler [lindex $ELNA_UNDER_TEST 0] + + # verify that the compiler exists + if { [is_remote host] || [which $compiler] != 0 } then { + set tmp [remote_exec host "$compiler -v"] + set status [lindex $tmp 0] + set output [lindex $tmp 1] + regexp " version \[^\n\r\]*" $output version + if { $status == 0 && [info exists version] } then { + if [is_remote host] { + clone_output "$compiler $version\n" + } else { + clone_output "[which $compiler] $version\n" + } + } else { + clone_output "Couldn't determine version of [which $compiler]\n" + } + } else { + # compiler does not exist (this should have already been detected) + warning "$compiler does not exist" + } +} + +# +# elna_init -- called at the start of each subdir of tests +# + +proc elna_init { args } { + global subdir + global gpp_initialized + global base_dir + global tmpdir + global libdir + global gluefile wrap_flags + global objdir srcdir + global ALWAYS_ELNAFLAGS + global TOOL_EXECUTABLE TOOL_OPTIONS + global ELNA_UNDER_TEST + global TESTING_IN_BUILD_TREE + global TEST_ALWAYS_FLAGS + + # We set LC_ALL and LANG to C so that we get the same error messages as expected. + setenv LC_ALL C + setenv LANG C + + if ![info exists ELNA_UNDER_TEST] then { + if [info exists TOOL_EXECUTABLE] { + set ELNA_UNDER_TEST $TOOL_EXECUTABLE + } else { + if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } { + set ELNA_UNDER_TEST [transform gelna] + } else { + set ELNA_UNDER_TEST [findfile $base_dir/../../gelna "$base_dir/../../gelna -B$base_dir/../../" [findfile $base_dir/gelna "$base_dir/gelna -B$base_dir/" [transform gelna]]] + } + } + } + + if ![is_remote host] { + if { [which $ELNA_UNDER_TEST] == 0 } then { + perror "ELNA_UNDER_TEST ($ELNA_UNDER_TEST) does not exist" + exit 1 + } + } + if ![info exists tmpdir] { + set tmpdir "/tmp" + } + + if [info exists gluefile] { + unset gluefile + } + + elna_maybe_build_wrapper "${tmpdir}/elna-testglue.o" + + set ALWAYS_ELNAFLAGS "" + + # TEST_ALWAYS_FLAGS are flags that should be passed to every + # compilation. They are passed first to allow individual + # tests to override them. + if [info exists TEST_ALWAYS_FLAGS] { + lappend ALWAYS_ELNAFLAGS "additional_flags=$TEST_ALWAYS_FLAGS" + } + + if [info exists TOOL_OPTIONS] { + lappend ALWAYS_ELNAFLAGS "additional_flags=$TOOL_OPTIONS" + } + + verbose -log "ALWAYS_ELNAFLAGS set to $ALWAYS_ELNAFLAGS" + + verbose "elna is initialized" 3 +} + +# +# elna_target_compile -- compile a source file +# + +proc elna_target_compile { source dest type options } { + global tmpdir + global gluefile wrap_flags + global ALWAYS_ELNAFLAGS + global ELNA_UNDER_TEST + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + lappend options "timeout=[timeout_value]" + lappend options "compiler=$ELNA_UNDER_TEST" + + set options [concat "$ALWAYS_ELNAFLAGS" $options] + set options [dg-additional-files-options $options $source $dest $type] + return [target_compile $source $dest $type $options] +} 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] diff --git a/testsuite/compilable/empty_proc.elna b/testsuite/compilable/empty_proc.elna new file mode 100644 index 0000000..fb07285 --- /dev/null +++ b/testsuite/compilable/empty_proc.elna @@ -0,0 +1,4 @@ +proc f() +end + +end. |
