forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LoongArch: Reimplement multilib build option handling.
Library build options from --with-multilib-list used to be processed with *self_spec, which missed the driver's initial canonicalization. This caused limitations on CFLAGS override and the use of driver-only options like -m[no]-lsx. The problem is solved by promoting the injection rules of --with-multilib-list options to the first element of DRIVER_SELF_SPECS, to make them execute before the canonialization. The library-build options are also hard-coded in the driver and can be used conveniently by the builders of other non-gcc libraries via the use of -fmultiflags. Bootstrapped and tested on loongarch64-linux-gnu. ChangeLog: * config-ml.in: Remove unneeded loongarch clause. * configure.ac: Register custom makefile fragments mt-loongarch-* for loongarch targets. * configure: Regenerate. config/ChangeLog: * mt-loongarch-mlib: New file. Pass -fmultiflags when building target libraries (FLAGS_FOR_TARGET). * mt-loongarch-elf: New file. * mt-loongarch-gnu: New file. gcc/ChangeLog: * config.gcc: Pass the default ABI via TM_MULTILIB_CONFIG. * config/loongarch/loongarch-driver.h: Invoke MLIB_SELF_SPECS before the driver canonicalization routines. * config/loongarch/loongarch.h: Move definitions of CC1_SPEC etc. to loongarch-driver.h * config/loongarch/t-linux: Move multilib-related definitions to t-multilib. * config/loongarch/t-multilib: New file. Inject library build options obtained from --with-multilib-list. * config/loongarch/t-loongarch: Same.
- Loading branch information
1 parent
68cb873
commit 227b18f
Showing
12 changed files
with
137 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include $(srcdir)/config/mt-loongarch-mlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include $(srcdir)/config/mt-gnu | ||
include $(srcdir)/config/mt-loongarch-mlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FLAGS_FOR_TARGET += -fmultiflags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# 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/>. | ||
|
||
# Helper definitions | ||
comma=, | ||
null := | ||
space := $(null) # | ||
exclude_1st = $(wordlist 2,$(words $1),$1) | ||
|
||
# Common definitions | ||
mlib_all := lp64d lp64f lp64s | ||
$(foreach i,$(mlib_all),$(eval MULTISUBDIR_$i := base/$i)) | ||
|
||
mlib_default := $(firstword $(subst $(comma), ,$(TM_MULTILIB_CONFIG))) | ||
mlib_all := $(filter-out $(mlib_default),$(mlib_all)) | ||
|
||
MULTILIB_OPTIONS := $(subst $(space),/,$(foreach i,$(mlib_all),mabi=$(i))) | ||
MULTILIB_DIRNAMES := $(foreach i,$(mlib_all),$(MULTISUBDIR_$(i))) | ||
|
||
# Customize builds with --with-multilib-list | ||
MULTILIB_REQUIRED := $(foreach i,$(call exclude_1st,\ | ||
$(subst $(comma), ,$(TM_MULTILIB_CONFIG))),\ | ||
$(firstword $(subst /, ,$(i)))) | ||
|
||
## spec rules for building libraries, triggered by -fmultiflags | ||
gen_mlib_spec = $(if $(word 2,$1),\ | ||
%{$(firstword $1):$(patsubst %,-%,$(call exclude_1st,$1)})) | ||
|
||
lib_build_spec = $(foreach mlib,\ | ||
$(call exclude_1st,$(subst $(comma), ,$(TM_MULTILIB_CONFIG))),\ | ||
$(call gen_mlib_spec,$(subst /, ,$(mlib)))) | ||
|
||
default_mlib_spec := %{fmultiflags:%{!mabi=*:-mabi=$(mlib_default)}} | ||
lib_build_spec := %{fmultiflags:$(lib_build_spec)} | ||
|
||
ifneq ($(TM_MULTILIB_CONFIG),) | ||
loongarch-multilib.h: | ||
@echo "#define MLIB_SELF_SPECS" \ | ||
"\"$(default_mlib_spec)\"," \ | ||
"\"$(lib_build_spec)\"," > $@ | ||
else | ||
loongarch-multilib.h: ; @touch $@ | ||
endif | ||
|
||
# Multiarch | ||
ifneq ($(call if_multiarch,yes),yes) | ||
# Define LA_DISABLE_MULTIARCH if multiarch is disabled. | ||
tm_defines += LA_DISABLE_MULTIARCH | ||
else | ||
# Only define MULTIARCH_DIRNAME when multiarch is enabled, | ||
# or it would always introduce ${target} into the search path. | ||
MULTIARCH_DIRNAME = $(LA_MULTIARCH_TRIPLET) | ||
endif |