Index | Thread | Search

From:
Martijn van Duren <openbsd+tech@list.imperialat.at>
Subject:
allow base-gcc to be build by clang
To:
tech@openbsd.org
Date:
Mon, 9 Nov 2026 12:23:36 +0100

Download raw body.

Thread
Sometimes you want a bit snappier machine to test something with
base-gcc. But if the compiler is identified as clang it forces
you to gcc, which creates a chicken-egg problem.

Building with egcc works fine, and modifying
gnu/usr.bin/cc/Makefile.inc's CC= would allow to create a working
gcc, but why install a package to do so. The diff below allows me to
build gcc, install it, and rebuild gcc with said gcc.

directive.c: struct directive's name is being used in conjunction with
  printf("%s"), same for dir, so these should be safe to remove the U.
lex.c: digraph_spellings are assigned to CPPCHAR_SIGNED_T in some places
  and char in other places, but the individual characters are accessed
  via index, which would treat them as a unsigned char anyway, so this
  appears to be treated as char anyway.
macro.c: result, is an unsigned char, pfile's date, and time are both
  unsigned char, and are constructed via sprintf, and pbuffer's
  timestamp is constructed with asctime.
So in cases it doesn't make sense to use U"".

OK?

martijn@

diff /usr/src
path + /usr/src
commit - d3bf47f4d896f1439490a2e148259917c27a4bc0
blob - 7fb142e48c798354c3639695ea00472db6b540c8
file + gnu/gcc/libcpp/directives.c
--- gnu/gcc/libcpp/directives.c
+++ gnu/gcc/libcpp/directives.c
@@ -187,7 +187,7 @@ DIRECTIVE_TABLE
    did use this notation in its preprocessed output.  */
 static const directive linemarker_dir =
 {
-  do_linemarker, U"#", 1, KANDR, IN_I
+  do_linemarker, "#", 1, KANDR, IN_I
 };
 
 #define SEEN_EOL() (pfile->cur_token[-1].type == CPP_EOF)
@@ -681,7 +681,7 @@ parse_include (cpp_reader *pfile, int *pangle_brackets
       const unsigned char *dir;
 
       if (pfile->directive == &dtable[T_PRAGMA])
-	dir = U"pragma dependency";
+	dir = "pragma dependency";
       else
 	dir = pfile->directive->name;
       cpp_error (pfile, CPP_DL_ERROR, "#%s expects \"FILENAME\" or <FILENAME>",
commit - d3bf47f4d896f1439490a2e148259917c27a4bc0
blob - 54e1b0b3e0cbcb28398b95cd83ac4f039996ae2b
file + gnu/gcc/libcpp/lex.c
--- gnu/gcc/libcpp/lex.c
+++ gnu/gcc/libcpp/lex.c
@@ -39,7 +39,7 @@ struct token_spelling
 };
 
 static const unsigned char *const digraph_spellings[] =
-{ U"%:", U"%:%:", U"<:", U":>", U"<%", U"%>" };
+{ "%:", "%:%:", "<:", ":>", "<%", "%>" };
 
 #define OP(e, s) { SPELL_OPERATOR, U s  },
 #define TK(e, s) { SPELL_ ## s,    U #e },
commit - d3bf47f4d896f1439490a2e148259917c27a4bc0
blob - be50c111e32ed70a0d8088c55efa9cf7eea71f1f
file + gnu/gcc/libcpp/macro.c
--- gnu/gcc/libcpp/macro.c
+++ gnu/gcc/libcpp/macro.c
@@ -154,7 +154,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashno
 		  {
 		    cpp_errno (pfile, CPP_DL_WARNING,
 			"could not determine file timestamp");
-		    pbuffer->timestamp = U"\"??? ??? ?? ??:??:?? ????\"";
+		    pbuffer->timestamp = "\"??? ??? ?? ??:??:?? ????\"";
 		  }
 	      }
 	  }
@@ -252,8 +252,8 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashno
 	      cpp_errno (pfile, CPP_DL_WARNING,
 			 "could not determine date and time");
 		
-	      pfile->date = U"\"??? ?? ????\"";
-	      pfile->time = U"\"??:??:??\"";
+	      pfile->date = "\"??? ?? ????\"";
+	      pfile->time = "\"??:??:??\"";
 	    }
 	}
 
commit - d3bf47f4d896f1439490a2e148259917c27a4bc0
blob - 2175463185b385cbd0048916a9d05f7a5a683fb3
file + gnu/usr.bin/cc/Makefile.inc
--- gnu/usr.bin/cc/Makefile.inc
+++ gnu/usr.bin/cc/Makefile.inc
@@ -3,11 +3,6 @@
 
 .include "../Makefile.inc"
 
-.if ${COMPILER_VERSION:L} == "clang"
-CC=	gcc
-CXX=	g++
-.endif
-
 # Sometimes this is .include'd several times...
 .if !defined(__CC_MAKEFILE_INC__)
 __CC_MAKEFILE_INC__= ${MFILE}