aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/i386/x-mingw32-utf8
blob: b5a6cfcf7023467e274685202c7966c33b0ade03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright (C) 2023 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
# 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/>.
#
#
# For mingw Windows hosts, embed a manifest that sets the active
# code page of the driver and compiler proper processes to utf8.
# This only has an effect when gcc is hosted on Windows version
# 1903 (May 2019 Update) or later.

# The resource .rc file references the utf8 .manifest file.
# Compile it into an object file using windres.
# The resulting .o file gets added to host_extra_gcc_objs in
# config.host for mingw hosts and gets linked into
# the driver as a .o file, so it's lack of symbols is OK.
utf8rc-mingw32.o : $(srcdir)/config/i386/utf8-mingw32.rc \
  $(srcdir)/config/i386/winnt-utf8.manifest
	$(WINDRES) $< $@

# Create an object file that just exports the global symbol
# HOST_EXTRA_OBJS_SYMBOL
sym-mingw32.o : $(srcdir)/config/i386/sym-mingw32.cc
	$(COMPILER) -c $<

# Combine the two object files into one which has both the
# compiled utf8 resource and the HOST_EXTRA_OBJS_SYMBOL symbol.
# The resulting .o file gets added to host_extra_objs in
# config.host for mingw hosts and gets archived into
# libbackend.a which gets linked into the compiler proper.
# If nothing references it into libbackend.a, it will not
# get linked into the compiler proper eventually.
# Therefore we need to request the symbol at compiler link time.
# -nostdlib is required for supporting old gcc versions that
# don't apply it automatically with -r.
utf8-mingw32.o : utf8rc-mingw32.o sym-mingw32.o
	$(COMPILER) -r -nostdlib utf8rc-mingw32.o sym-mingw32.o -o $@

# Force compilers to link against the utf8 resource by
# requiring the symbol to be defined.
# Otherwise the object file won't get linked in the compilers
# because nothing is referencing it in libbackend.a
# This is expected because the resource object is not supposed
# to have any symbols, it just has to be linked into the
# executable in order for Windows to use the utf8 code page.
# Some build environments are passing these flags to other
# programs as well, so make the symbol definition optional
# such that these programs don't fail to build when they
# don't find it.
$(COMPILERS) : override LDFLAGS += -Wl,--undefined=HOST_EXTRA_OBJS_SYMBOL