From aa9339a9f3060f3e6a7ecde451fe1dd930962c07 Mon Sep 17 00:00:00 2001 From: Emmanuel Charpentier Date: Tue, 17 Aug 2021 16:35:43 +0200 Subject: [PATCH 01/91] Half_angle : code (not yet commented). --- src/sage/symbolic/expression.pyx | 7 ++++ src/sage/symbolic/expression_conversions.py | 38 +++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index 42ab4ae25a1..a35edafa1a2 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -5712,6 +5712,13 @@ cdef class Expression(CommutativeRingElement): from sage.symbolic.expression_conversions import SubstituteFunction return SubstituteFunction(self, original, new)() + def half_angle(self): + """ + TODO + """ + from sage.symbolic.expression_conversions import HalfAngle + return HalfAngle(self)() + def substitution_delayed(self, pattern, replacement): """ Replace all occurrences of pattern by the result of replacement. diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 63cef49e0b9..562e17442bb 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -2375,6 +2375,44 @@ def derivative(self, ex, operator): else: return operator(*[self(_) for _ in ex.operands()]) +# Half_angle transformation. Sometimes useful in integration + +class HalfAngle(ExpressionTreeWalker): + # Code executed once at first class reference : create canned formulae. + from sage.functions.hyperbolic import sinh, cosh, sech, csch, tanh, coth + from sage.functions.trig import sin, cos, sec, csc, tan, cot + from sage.rings.integer import Integer + from sage.calculus.var import function + from sage.symbolic.ring import SR + x = SR.var("x") + HalvesDict = { + sin: Integer(2)*tan(Integer(1)/Integer(2)*x)/(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), + cos: -(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), + tan: -Integer(2)*tan(Integer(1)/Integer(2)*x)/(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), + csc: Integer(1)/Integer(2)*(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/tan(Integer(1)/Integer(2)*x).function(x), + sec: -(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), + cot: -Integer(1)/Integer(2)*(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/tan(Integer(1)/Integer(2)*x).function(x), + sinh: -Integer(2)*tanh(Integer(1)/Integer(2)*x)/(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), + cosh: -(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), + tanh: Integer(2)*tanh(Integer(1)/Integer(2)*x)/(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), + csch: -Integer(1)/Integer(2)*(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/tanh(Integer(1)/Integer(2)*x).function(x), + sech: -(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), + coth: Integer(1)/Integer(2)*(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/tanh(Integer(1)/Integer(2)*x).function(x) + } + Halves = list(HalvesDict.keys()) + def __init__(self, ex): + """ + TODO + """ + self.ex = ex + def composition(self, ex, op): + """ + TODO + """ + if op in self.Halves: + return self.HalvesDict.get(op)(*[self(_) for _ in ex.operands()]) + return super(HalfAngle, self).composition(ex, op) + class HoldRemover(ExpressionTreeWalker): def __init__(self, ex, exclude=None): """ From a9e702c301f31a5294e1ac69cfba8bd824530d9b Mon Sep 17 00:00:00 2001 From: Emmanuel Charpentier Date: Tue, 17 Aug 2021 23:02:57 +0200 Subject: [PATCH 02/91] Half_angle : documentation. --- src/sage/symbolic/expression.pyx | 32 +++++++++++++++++++-- src/sage/symbolic/expression_conversions.py | 9 ++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index a35edafa1a2..623a1e4a191 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -5713,8 +5713,36 @@ cdef class Expression(CommutativeRingElement): return SubstituteFunction(self, original, new)() def half_angle(self): - """ - TODO + """Replaces all occurrences of trigonometric (or hyperbolic) + functions by rational fractions of the (hyperbolic) tangeant + of half the original argument. + + This can be helpful in situation where one needs to underscore + the algebraic structure of an expression (e. g. integration). + + Note that this method has no direct relation with the + ``half_angles`` argument of the :meth:`trig_expand` method. + + EXAMPLES:: + + sage: x, t = var("x, t") + sage: cos(x).half_angle().subs(tan(x/2)==t) + -(t^2 - 1)/(t^2 + 1) + + Note that this structure underscoring works better after expansion : + + sage: x, t = var("x, t") + sage: (cos(3*x)/(4-cos(x))).half_angle().subs(tan(x/2)==t).simplify_full() + (2*(t^2 + 1)*cos(3/2*x)^2 - t^2 - 1)/(5*t^2 + 3) + sage: (cos(3*x)/(4-cos(x))).trig_expand().half_angle().subs(tan(x/2)==t).simplify_full() + -(t^6 - 15*t^4 + 15*t^2 - 1)/(5*t^6 + 13*t^4 + 11*t^2 + 3) + + TESTS: + + sage: all([bool(((u(x)==u(x).half_angle()).subs(x==2*x).trig_simplify())) \ + for u in (sin, cos, tan, csc, sec, cot, \ + sinh, cosh, tanh, csch, sech, coth)]) + True """ from sage.symbolic.expression_conversions import HalfAngle return HalfAngle(self)() diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 562e17442bb..39c0a148c14 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -2402,12 +2402,17 @@ class HalfAngle(ExpressionTreeWalker): Halves = list(HalvesDict.keys()) def __init__(self, ex): """ - TODO + A class that walks a symbolic expression tree, replacing each occurrence of a trigonometric or hyperbolic function by its expression as a rational fraction in (hyperbolic) tangent of half the original argument. """ self.ex = ex def composition(self, ex, op): """ - TODO + EXAMPLES:: + + sage: from sage.symbolic.expression_conversions import HalfAngle + sage: x, t = SR.var("x, t") + sage: HalfAngle(cos(3*x)/(4-cos(x)).trig_expand())().subs(tan(x/2)==t).simplify_full() + (2*(t^2 + 1)*cos(3/2*x)^2 - t^2 - 1)/(5*t^2 + 3) """ if op in self.Halves: return self.HalvesDict.get(op)(*[self(_) for _ in ex.operands()]) From b5899f7a3017e0146fb1b89a4396fe1b6bae5d88 Mon Sep 17 00:00:00 2001 From: Emmanuel Charpentier Date: Wed, 18 Aug 2021 09:20:59 +0200 Subject: [PATCH 03/91] Half-angle : fix minor lint squabbles. --- src/sage/symbolic/expression.pyx | 5 +++-- src/sage/symbolic/expression_conversions.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index 623a1e4a191..acfd002b838 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -5720,8 +5720,9 @@ cdef class Expression(CommutativeRingElement): This can be helpful in situation where one needs to underscore the algebraic structure of an expression (e. g. integration). - Note that this method has no direct relation with the - ``half_angles`` argument of the :meth:`trig_expand` method. + It should be noted that this method has no direct relation + with the ``half_angles`` argument of the :meth:`trig_expand` + method. EXAMPLES:: diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 39c0a148c14..264fff7deb7 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -1011,11 +1011,11 @@ def pyobject(self, ex, obj): sage: ex._fricas_()^2 # optional - fricas +-+ - (4 + 2 %i)\|2 + 5 + 4 %i + (4 + 2 %i)|2 + 5 + 4 %i sage: (ex^2)._fricas_() # optional - fricas +-+ - (4 + 2 %i)\|2 + 5 + 4 %i + (4 + 2 %i)|2 + 5 + 4 %i """ try: From a60e101f5ff5cd08baa787e29b3b3e02d3e1cc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Leli=C3=A8vre?= Date: Wed, 18 Aug 2021 15:18:16 +0200 Subject: [PATCH 04/91] 32389: Improve formatting --- src/sage/symbolic/expression.pyx | 36 ++++++++------- src/sage/symbolic/expression_conversions.py | 50 +++++++++++++-------- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index acfd002b838..8a445c2922c 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -5000,7 +5000,7 @@ cdef class Expression(CommutativeRingElement): is True. - ``times`` - (default: True) Controls the product - rule, expansion of products (e.g. sin(2\*x)) will take place only + rule, expansion of products (e.g. `sin(2*x)`) will take place only if times is True. @@ -5713,36 +5713,38 @@ cdef class Expression(CommutativeRingElement): return SubstituteFunction(self, original, new)() def half_angle(self): - """Replaces all occurrences of trigonometric (or hyperbolic) - functions by rational fractions of the (hyperbolic) tangeant + """ + Replace all occurrences of trigonometric (or hyperbolic) + functions by rational fractions of the (hyperbolic) tangent of half the original argument. - This can be helpful in situation where one needs to underscore - the algebraic structure of an expression (e. g. integration). + This can help highlight the algebraic structure of an expression, + which can be useful e.g. for integration. - It should be noted that this method has no direct relation - with the ``half_angles`` argument of the :meth:`trig_expand` - method. + This method has no direct relation with the ``half_angles`` + argument of the :meth:`trig_expand` method. EXAMPLES:: sage: x, t = var("x, t") - sage: cos(x).half_angle().subs(tan(x/2)==t) + sage: cos(x).half_angle().subs(tan(x/2) == t) -(t^2 - 1)/(t^2 + 1) - Note that this structure underscoring works better after expansion : + Note that this structure highlighting works better after expansion:: sage: x, t = var("x, t") - sage: (cos(3*x)/(4-cos(x))).half_angle().subs(tan(x/2)==t).simplify_full() + sage: a = (cos(3*x)/(4-cos(x))) + sage: b = a.trig_expand() + sage: a.half_angle().subs(tan(x/2) == t).simplify_full() (2*(t^2 + 1)*cos(3/2*x)^2 - t^2 - 1)/(5*t^2 + 3) - sage: (cos(3*x)/(4-cos(x))).trig_expand().half_angle().subs(tan(x/2)==t).simplify_full() + sage: b.half_angle().subs(tan(x/2) == t).simplify_full() -(t^6 - 15*t^4 + 15*t^2 - 1)/(5*t^6 + 13*t^4 + 11*t^2 + 3) - TESTS: + TESTS:: - sage: all([bool(((u(x)==u(x).half_angle()).subs(x==2*x).trig_simplify())) \ - for u in (sin, cos, tan, csc, sec, cot, \ - sinh, cosh, tanh, csch, sech, coth)]) + sage: all((u(x) == u(x).half_angle()).subs(x == 2*x).trig_simplify() + ....: for u in (sin, cos, tan, csc, sec, cot, + ....: sinh, cosh, tanh, csch, sech, coth)) True """ from sage.symbolic.expression_conversions import HalfAngle @@ -7603,7 +7605,7 @@ cdef class Expression(CommutativeRingElement): return new_Expression_from_GEx(self._parent, x) def gosper_term(self, n): - """ + r""" Return Gosper's hypergeometric term for ``self``. Suppose ``f``=``self`` is a hypergeometric term such that: diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 264fff7deb7..335c41e360e 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -1011,11 +1011,11 @@ def pyobject(self, ex, obj): sage: ex._fricas_()^2 # optional - fricas +-+ - (4 + 2 %i)|2 + 5 + 4 %i + (4 + 2 %i)\|2 + 5 + 4 %i sage: (ex^2)._fricas_() # optional - fricas +-+ - (4 + 2 %i)|2 + 5 + 4 %i + (4 + 2 %i)\|2 + 5 + 4 %i """ try: @@ -2378,44 +2378,56 @@ def derivative(self, ex, operator): # Half_angle transformation. Sometimes useful in integration class HalfAngle(ExpressionTreeWalker): - # Code executed once at first class reference : create canned formulae. + """ + A class that walks a symbolic expression tree, replacing each + occurrence of a trigonometric or hyperbolic function by its + expression as a rational fraction in the (hyperbolic) tangent + of half the original argument. + """ + # Code executed once at first class reference: create canned formulae. from sage.functions.hyperbolic import sinh, cosh, sech, csch, tanh, coth from sage.functions.trig import sin, cos, sec, csc, tan, cot from sage.rings.integer import Integer from sage.calculus.var import function from sage.symbolic.ring import SR x = SR.var("x") + one = Integer(1) + two = Integer(2) + half = one/two HalvesDict = { - sin: Integer(2)*tan(Integer(1)/Integer(2)*x)/(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), - cos: -(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), - tan: -Integer(2)*tan(Integer(1)/Integer(2)*x)/(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), - csc: Integer(1)/Integer(2)*(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/tan(Integer(1)/Integer(2)*x).function(x), - sec: -(tan(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), - cot: -Integer(1)/Integer(2)*(tan(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/tan(Integer(1)/Integer(2)*x).function(x), - sinh: -Integer(2)*tanh(Integer(1)/Integer(2)*x)/(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), - cosh: -(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1)).function(x), - tanh: Integer(2)*tanh(Integer(1)/Integer(2)*x)/(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), - csch: -Integer(1)/Integer(2)*(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/tanh(Integer(1)/Integer(2)*x).function(x), - sech: -(tanh(Integer(1)/Integer(2)*x)**Integer(2) - Integer(1))/(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1)).function(x), - coth: Integer(1)/Integer(2)*(tanh(Integer(1)/Integer(2)*x)**Integer(2) + Integer(1))/tanh(Integer(1)/Integer(2)*x).function(x) + sin: two*tan(half*x)/(tan(half*x)**2 + one).function(x), + cos: -(tan(half*x)**2 - one)/(tan(half*x)**2 + one).function(x), + tan: -two*tan(half*x)/(tan(half*x)**2 - one).function(x), + csc: half*(tan(half*x)**2 + one)/tan(half*x).function(x), + sec: -(tan(half*x)**2 + one)/(tan(half*x)**2 - one).function(x), + cot: -half*(tan(half*x)**2 - one)/tan(half*x).function(x), + sinh: -two*tanh(half*x)/(tanh(half*x)**2 - one).function(x), + cosh: -(tanh(half*x)**2 + one)/(tanh(half*x)**2 - one).function(x), + tanh: two*tanh(half*x)/(tanh(half*x)**2 + one).function(x), + csch: -half*(tanh(half*x)**2 - one)/tanh(half*x).function(x), + sech: -(tanh(half*x)**2 - one)/(tanh(half*x)**2 + one).function(x), + coth: half*(tanh(half*x)**2 + one)/tanh(half*x).function(x) } - Halves = list(HalvesDict.keys()) + Halves = list(HalvesDict) def __init__(self, ex): """ - A class that walks a symbolic expression tree, replacing each occurrence of a trigonometric or hyperbolic function by its expression as a rational fraction in (hyperbolic) tangent of half the original argument. + Initialize. """ self.ex = ex def composition(self, ex, op): """ + Compose. + EXAMPLES:: sage: from sage.symbolic.expression_conversions import HalfAngle sage: x, t = SR.var("x, t") - sage: HalfAngle(cos(3*x)/(4-cos(x)).trig_expand())().subs(tan(x/2)==t).simplify_full() + sage: a = HalfAngle(cos(3*x)/(4-cos(x)).trig_expand())() + sage: a.subs(tan(x/2) == t).simplify_full() (2*(t^2 + 1)*cos(3/2*x)^2 - t^2 - 1)/(5*t^2 + 3) """ if op in self.Halves: - return self.HalvesDict.get(op)(*[self(_) for _ in ex.operands()]) + return self.HalvesDict.get(op)(*[self(x) for x in ex.operands()]) return super(HalfAngle, self).composition(ex, op) class HoldRemover(ExpressionTreeWalker): From 7a566659011b142f2fa52957491a824ee54b41c5 Mon Sep 17 00:00:00 2001 From: Aaron Date: Wed, 14 Feb 2024 14:12:45 -0500 Subject: [PATCH 05/91] Added methods to generate covering arrays and a main CA function to call them based on inputted paramters. Added methods include direct implementation of optimal arrays in the database of small combinatorial designs, methods that create a CA(N,t=2,k,v=2), for either k or N inputted and a recursive method that removes columns from a larger array. Added required documentation and reference for new methods. --- src/doc/en/reference/references/index.rst | 22 +- src/sage/combinat/designs/covering_array.py | 193 ++++++++- src/sage/combinat/designs/database.py | 450 +++++++++++++++++++- 3 files changed, 654 insertions(+), 11 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index 7921aea3bf5..a8fec99e887 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -1780,8 +1780,8 @@ REFERENCES: With an appendix by Ernst Kani. Canad. Math. Bull. 48 (2005), no. 1, 16--31. -.. [Colb2004] C.J. Colbourn. “Combinatorial aspects of covering arrays”. - Matematiche (Catania) 59 (2004), pp. 125–172. +.. [Colb2004] C.J. Colbourn. *Combinatorial aspects of covering arrays*. + Matematiche (Catania) 59 (2004), pp. 125-172. .. [Col2004] Pierre Colmez, Invariant `\mathcal{L}` et derivees de valeurs propres de Frobenius, preprint, 2004. @@ -3686,6 +3686,10 @@ REFERENCES: .. [Kas2018] András Kaszanyitzky. *The GraftalLace Cellular Automata*. Preprint, :arxiv:`1805.11532`. +.. [Kat1973] G. Katona. *Two applications (for search theory and truth + functions) of Sperner type theorems*. Periodica Math., + 3:19-26, 1973. + .. [Kat1991] Nicholas M. Katz, *Exponential sums and differential equations*, Princeton University Press, Princeton NJ, 1991. @@ -3983,6 +3987,9 @@ REFERENCES: .. [KS] Sheldon Katz and Stein Arild Stromme, "Schubert", A Maple package for intersection theory and enumerative geometry. +.. [KS1973] D. Kleitman and J. Spencer. *Families of k-independent sets*. + Discrete Math, 6:255-262, 1973. + .. [KS1998] Maximilian Kreuzer and Harald Skarke, *Classification of Reflexive Polyhedra in Three Dimensions*, :arxiv:`hep-th/9805190` @@ -4985,6 +4992,9 @@ REFERENCES: :doi:`10.1007/s00453-006-1225-y`, http://www.cs.uoi.gr/~stavros/C-Papers/C-2004-SODA.pdf +.. [Nur2004] K. Nurmela. *Upper bounds for covering arrays by tabu search*. + Discrete Applied Math., 138 (2004), 143-152. + .. [NWS2002] Newman, M.E.J., Watts, D.J. and Strogatz, S.H. *Random graph models of social networks*. Proc. Nat. Acad. Sci. USA 99:1 (2002), 2566-2572. :doi:`10.1073/pnas.012582999` @@ -5729,8 +5739,8 @@ REFERENCES: .. [SloaHada] \N.J.A. Sloane's Library of Hadamard Matrices, at https://neilsloane.com/hadamard/ -.. [SMC2006] \G.B. Sherwood, S.S Martirosyan, and C.J. Colbourn, "Covering - arrays of higher strength from permutation vectors". J. Combin. +.. [SMC2006] \G.B. Sherwood, S.S Martirosyan, and C.J. Colbourn, *Covering + arrays of higher strength from permutation vectors*. J. Combin. Designs, 14 (2006) pp. 202-213. .. [SMMK2013] \T. Suzaki, K. Minematsu, S. Morioka, and E. Kobayashi, @@ -6414,8 +6424,8 @@ REFERENCES: .. [Wat2010] Watkins, David S. Fundamentals of Matrix Computations, Third Edition. Wiley, Hoboken, New Jersey, 2010. -.. [WC2007] \R.A. Walker II, and C.J. Colbourn, "Perfect Hash Families: - Constructions and Existence". J. Math. Crypt. 1 (2007), +.. [WC2007] \R.A. Walker II, and C.J. Colbourn, *Perfect Hash Families: + Constructions and Existence*. J. Math. Crypt. 1 (2007), pp.125-150 .. [Web2007] James Webb. *Game theory: decisions, interaction and diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index 1596c708152..c353944531b 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -16,12 +16,16 @@ .. csv-table:: :class: contentstable - :widths: 30, 70 + :widths: 50, 50 :delim: | :meth:`~sage.combinat.designs.designs_pyx.is_covering_array` | Check that an input list of lists is a `CA(N;t,k,v)`. - :meth:`~sage.combinat.designs.covering_array.CA_relabel` | Return a relabelled version of the CA. - :meth:`~sage.combinat.designs.covering_array.CA_standard_label` | Return a version of the CA relabelled to symbols `(0,\dots,n-1)`. + :meth:`~sage.combinat.designs.covering_array.CA_relabel` | Return a relabelled version of the `CA`. + :meth:`~sage.combinat.designs.covering_array.CA_standard_label` | Return a version of the `CA` relabelled to symbols `(0,\dots,n-1)`. + :meth:`~sage.combinat.designs.covering_array.truncate_columns` | Return an array with `k` columns from a larger one. + :meth:`~sage.combinat.designs.covering_array.Kleitman_Spencer_Katona` | Return a `CA(N; 2, k, 2)` using N as input. + :meth:`~sage.combinat.designs.covering_array.column_Kleitman_Spencer_Katona` | Return a `CA(N; 2, k, 2)` using k as input. + :meth:`~sage.combinat.designs.covering_array.covering_array` | Return a `CA` with given parameters. REFERENCES: @@ -50,3 +54,186 @@ from .orthogonal_arrays import OA_relabel, OA_standard_label CA_relabel = OA_relabel CA_standard_label = OA_standard_label + +def truncate_columns(array, k): + r""" + Return a covering array with `k` columns, obtained by removing excess + columns from a larger covering array. + + INPUT: + + - ``array`` -- the array to be truncated. + + - ``k`` -- the number of columns desired. Must be less than the + number of columns in ``array``. + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.covering_array import truncate_columns + sage: from sage.combinat.designs.database import ca_11_2_5_3 + sage: C = ca_11_2_5_3() + sage: D = truncate_columns(C,7) + Traceback (most recent call last): + ... + ValueError: array only has 5 columns + sage: E = truncate_columns(C,4) + sage: is_covering_array(E,parameters=True) + (True, (11, 2, 4, 3)) + + """ + oldk = len(array[0]) + + if oldk == k: + return array + + elif oldk < k: + raise ValueError("array only has {} columns".format(oldk)) + + else: + result = [] + for row in array: + result.append(row[:k]) + return result + +def Kleitman_Spencer_Katona(N): + r""" + Return a `CA(N; 2, k, 2)` where `k = \binom {N-1}{\lceil \frac{N}{2} \rceil}`. + + INPUT: + + - ``N`` -- the number of rows in the array, must be an integer greater + than 3 since any smaller would not produce enough columns for a + strength 2 array. + + This construction is referenced in [Colb2004]_ from [KS1973]_ and [Kat1973]_ + + **Construction** + + Take all distinct binary `N`-tuples of weight `\frac{N}{2}` that have a 0 + in the first position and place them as columns in an array. + + EXAMPLES:: + + sage: from sage.combinat.designs.covering_array import Kleitman_Spencer_Katona + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: C = Kleitman_Spencer_Katona(2) + Traceback (most recent call last): + ... + ValueError: N must be greater than 3 + sage: C = Kleitman_Spencer_Katona(5) + sage: is_covering_array(C,parameters=True) + (True, (5, 2, 4, 2)) + + """ + from math import ceil + from itertools import combinations + + if N < 4: + raise ValueError("N must be greater than 3") + + result = [] + for p in combinations(range(N-1), ceil(N/2)): + S = [0]*N + for i in p: + S[i] = 1 + result.append(S) + return(list(map(list, zip(*result)))) + +def column_Kleitman_Spencer_Katona(k): + r""" + Return a covering array with `k` columns using the Kleitman Spencer Katona + method. + + See :func:`~sage.combinat.designs.covering_array.Kleitman_Spencer_Katona` + + INPUT: + + - ``k`` -- the number of columns in the array, must be an integer + greater than 3 since any smaller is a trivial array for strength 2. + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.covering_array import column_Kleitman_Spencer_Katona + sage: C = column_Kleitman_Spencer_Katona(20) + sage: is_covering_array(C,parameters=True) + (True, (8, 2, 20, 2)) + sage: column_Kleitman_Spencer_Katona(25000) + Traceback (most recent call last): + ... + AssertionError: not implemented for k > 24310 + + """ + assert k <= 24310, "not implemented for k > 24310" + + kdict = {3:4,4:5,10:6,15:7,35:8,56:9,126:10,210:11,462:12,792:13, + 1716:14,3003:15,6435:16,11440:17,24310:18} + + for ki in kdict: + if k <= ki: + N = kdict[ki] + break + return truncate_columns(Kleitman_Spencer_Katona(N), k) + +def covering_array(strength, number_columns, levels): + r""" + Build a `CA(N; t, k, v)` using direct constructions, where `N` is the + smallest size known. + + INPUT: + + - ``strength`` (integer) -- the parameter `t` of the covering array, + such that in any selection of `t` columns of the array, every `t` + -tuple appears at least once. + + - ``levels`` (integer) -- the parameter `v` which is the number of + unique symbols that appear in the covering array. + + - ``number_columns`` (integer) -- the number of columns desired for + the covering array. + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.covering_array import covering_array + sage: C1 = covering_array(2, 7, 3) + sage: is_covering_array(C1,parameters=True) + (True, (12, 2, 7, 3)) + sage: C2 = covering_array(2, 11, 2) + sage: is_covering_array(C2,parameters=True) + (True, (7, 2, 11, 2)) + sage: C3 = covering_array(2, 8, 7) + sage: is_covering_array(C3,parameters=True) + (True, (49, 2, 8, 7)) + sage: C4 = covering_array(3, 9, 3) + Traceback (most recent call last): + ... + ValueError: CAs and OAs only implemented for strength 2 + sage: C5 = covering_array(2, 50, 7) + No direct construction known and/or implemented for a CA(N; 2, 50, 7) + + """ + from sage.combinat.designs.orthogonal_arrays import orthogonal_array + + if strength != 2: + raise ValueError("CAs and OAs only implemented for strength 2") + + elif levels == 2: + return column_Kleitman_Spencer_Katona(number_columns) + + elif 3 <= levels <= 6: + import sage.combinat.designs.database as DB + for i in DB.CA_constructions[(strength, levels)]: + if number_columns <= i[1]: + CA = "ca_{}_{}_{}_{}".format(i[0], strength, i[1], levels) + f = getattr(DB, CA) + return truncate_columns(f(), number_columns) + + elif orthogonal_array(number_columns, levels, existence=True): + return orthogonal_array(number_columns, levels) + + else: + print("No direct construction known and/or implemented for a CA(N; {}, {}, {})".format( + strength, number_columns, levels)) + return \ No newline at end of file diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index 5eb2b90802a..1e87ebac538 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -12,6 +12,8 @@ This module implements: +- {LIST_OF_CA_CONSTRUCTIONS} + - {LIST_OF_OA_CONSTRUCTIONS} - {LIST_OF_MOLS_CONSTRUCTIONS} @@ -5033,6 +5035,449 @@ def BIBD_56_11_2(): k, ', '.join('`{}`'.format(q) for q in sorted(EDS[k]) if EDS[k][q] is not False)) for k in sorted(EDS)) +def ca_11_2_5_3(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_11_2_5_3 + sage: C = ca_11_2_5_3() + sage: is_covering_array(C,2,3) + True + + """ + return [[0, 0, 1, 0, 1], + [0, 0, 2, 1, 0], + [0, 1, 0, 1, 2], + [0, 2, 1, 2, 2], + [1, 0, 0, 2, 1], + [1, 1, 1, 2, 0], + [1, 1, 2, 0, 2], + [1, 2, 2, 1, 1], + [2, 0, 2, 2, 2], + [2, 1, 1, 1, 1], + [2, 2, 0, 0, 0]] + +def ca_12_2_7_3(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_12_2_7_3 + sage: C = ca_12_2_7_3() + sage: is_covering_array(C,2,3) + True + + """ + return [[0, 0, 0, 2, 2, 0, 0], + [0, 0, 2, 1, 1, 1, 1], + [0, 1, 0, 0, 0, 1, 2], + [0, 2, 1, 2, 0, 2, 1], + [1, 0, 2, 0, 0, 2, 0], + [1, 1, 1, 1, 2, 0, 1], + [1, 1, 1, 2, 1, 1, 0], + [1, 2, 0, 1, 1, 2, 2], + [2, 0, 1, 0, 1, 0, 2], + [2, 1, 2, 2, 2, 2, 2], + [2, 2, 0, 0, 2, 1, 1], + [2, 2, 2, 1, 0, 0, 0]] + +def ca_13_2_9_3(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_13_2_9_3 + sage: C = ca_13_2_9_3() + sage: is_covering_array(C,2,3) + True + + """ + return [[0, 0, 0, 2, 0, 2, 2, 2, 0], + [0, 0, 2, 0, 1, 1, 1, 2, 1], + [0, 1, 1, 1, 2, 0, 1, 2, 0], + [0, 1, 2, 1, 0, 1, 2, 0, 2], + [0, 2, 2, 2, 2, 1, 0, 1, 0], + [1, 0, 1, 0, 2, 1, 2, 0, 0], + [1, 0, 2, 1, 2, 2, 0, 2, 2], + [1, 1, 0, 0, 0, 0, 0, 1, 1], + [1, 2, 0, 2, 1, 0, 1, 0, 2], + [2, 0, 2, 1, 1, 0, 2, 1, 0], + [2, 1, 1, 2, 1, 2, 0, 0, 1], + [2, 2, 0, 1, 2, 1, 2, 2, 1], + [2, 2, 1, 0, 0, 2, 1, 1, 2]] + +def ca_14_2_10_3(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_14_2_10_3 + sage: C = ca_14_2_10_3() + sage: is_covering_array(C,2,3) + True + + """ + return [[0, 0, 0, 0, 2, 2, 2, 1, 1, 0], + [0, 0, 0, 2, 1, 0, 0, 2, 1, 1], + [0, 0, 1, 1, 1, 2, 1, 0, 2, 2], + [0, 1, 0, 2, 0, 1, 2, 0, 1, 2], + [0, 2, 2, 2, 1, 2, 2, 1, 0, 0], + [1, 0, 2, 1, 0, 1, 1, 1, 1, 1], + [1, 1, 1, 2, 1, 1, 1, 2, 2, 0], + [1, 1, 2, 0, 0, 2, 2, 2, 2, 1], + [1, 1, 2, 1, 0, 0, 0, 0, 0, 0], + [1, 2, 0, 1, 2, 0, 1, 2, 2, 2], + [2, 0, 0, 0, 1, 0, 1, 2, 0, 2], + [2, 1, 2, 2, 2, 2, 0, 1, 2, 2], + [2, 2, 1, 0, 2, 1, 0, 0, 0, 1], + [2, 2, 1, 1, 0, 0, 2, 1, 1, 0]] + +def ca_15_2_20_3(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from [Nur2004]_ + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_15_2_20_3 + sage: C = ca_15_2_20_3() + sage: is_covering_array(C,2,3) + True + + """ + return [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [0, 0, 0, 0, 0, 1, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], + [0, 1, 1, 1, 1, 0, 1, 2, 2, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2], + [0, 2, 2, 2, 2, 2, 2, 0, 1, 0, 0, 0, 0, 1, 2, 2, 0, 1, 1, 1], + [1, 0, 1, 1, 1, 2, 2, 0, 1, 0, 1, 1, 2, 0, 0, 1, 1, 0, 1, 2], + [1, 1, 2, 2, 2, 1, 0, 1, 0, 2, 1, 1, 0, 0, 2, 1, 2, 2, 1, 0], + [1, 2, 0, 1, 2, 0, 2, 1, 0, 2, 0, 2, 2, 1, 0, 2, 1, 0, 2, 1], + [1, 2, 1, 0, 2, 2, 1, 2, 0, 1, 2, 1, 1, 0, 1, 2, 0, 2, 0, 1], + [1, 2, 1, 2, 0, 2, 1, 1, 2, 2, 1, 0, 1, 2, 0, 0, 2, 1, 0, 0], + [2, 0, 2, 2, 2, 0, 1, 2, 2, 1, 2, 2, 0, 2, 2, 0, 1, 0, 1, 2], + [2, 1, 0, 2, 1, 2, 0, 2, 2, 2, 1, 2, 2, 0, 1, 2, 0, 1, 2, 0], + [2, 1, 2, 0, 1, 1, 2, 0, 2, 1, 0, 1, 1, 2, 1, 0, 2, 0, 2, 1], + [2, 1, 2, 1, 0, 1, 2, 2, 1, 1, 2, 0, 2, 1, 0, 0, 1, 2, 0, 0], + [2, 2, 1, 1, 1, 1, 0, 1, 0, 0, 2, 2, 1, 2, 2, 1, 0, 1, 0, 2]] + +def ca_19_2_6_4(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_19_2_6_4 + sage: C = ca_19_2_6_4() + sage: is_covering_array(C,2,4) + True + + """ + return [[0, 0, 0, 2, 0, 0], + [0, 0, 1, 0, 1, 1], + [0, 1, 3, 1, 2, 1], + [0, 2, 2, 3, 0, 2], + [0, 3, 3, 2, 3, 3], + [1, 0, 3, 1, 1, 2], + [1, 1, 0, 3, 1, 3], + [1, 1, 2, 0, 3, 0], + [1, 2, 1, 2, 2, 0], + [1, 3, 1, 3, 0, 1], + [2, 0, 2, 3, 2, 3], + [2, 1, 1, 2, 3, 2], + [2, 2, 0, 1, 3, 1], + [2, 2, 3, 0, 0, 3], + [2, 3, 2, 1, 1, 0], + [3, 0, 3, 3, 3, 0], + [3, 1, 1, 1, 0, 3], + [3, 2, 2, 2, 1, 1], + [3, 3, 0, 0, 2, 2]] + +def ca_21_2_7_4(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + This CA is also uniform. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_21_2_7_4 + sage: C = ca_21_2_7_4() + sage: is_covering_array(C,2,4) + True + + """ + return [[0, 0, 1, 0, 0, 0, 0], + [0, 0, 3, 1, 1, 1, 1], + [0, 1, 1, 2, 2, 2, 2], + [0, 1, 2, 3, 0, 1, 3], + [0, 2, 0, 3, 3, 0, 2], + [0, 3, 1, 3, 3, 3, 1], + [1, 0, 0, 3, 2, 3, 3], + [1, 1, 3, 1, 3, 3, 0], + [1, 2, 1, 2, 1, 0, 3], + [1, 2, 3, 2, 0, 2, 1], + [1, 3, 2, 0, 1, 1, 2], + [2, 0, 3, 0, 3, 2, 3], + [2, 1, 2, 1, 2, 0, 1], + [2, 2, 1, 1, 0, 3, 2], + [2, 2, 2, 3, 1, 2, 0], + [2, 3, 0, 2, 3, 1, 0], + [3, 0, 2, 2, 3, 3, 2], + [3, 1, 0, 0, 1, 3, 1], + [3, 2, 1, 0, 2, 1, 0], + [3, 3, 0, 1, 0, 2, 3], + [3, 3, 3, 3, 2, 0, 2]] + +def ca_29_2_7_5(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_29_2_7_5 + sage: C = ca_29_2_7_5() + sage: is_covering_array(C,2,5) + True + + """ + return [[0, 2, 2, 3, 0, 0, 0], + [1, 4, 3, 4, 2, 3, 0], + [2, 3, 0, 0, 4, 2, 0], + [3, 0, 1, 2, 3, 4, 0], + [4, 1, 4, 1, 1, 1, 0], + [0, 0, 2, 4, 1, 2, 1], + [1, 2, 4, 0, 2, 4, 1], + [1, 3, 1, 2, 1, 0, 1], + [2, 1, 2, 2, 4, 3, 1], + [3, 3, 3, 1, 0, 1, 1], + [4, 4, 0, 3, 3, 0, 1], + [0, 1, 3, 0, 3, 0, 2], + [1, 0, 3, 3, 4, 1, 2], + [2, 2, 1, 4, 3, 1, 2], + [2, 4, 4, 2, 0, 2, 2], + [3, 2, 0, 1, 1, 3, 2], + [4, 3, 2, 4, 2, 4, 2], + [0, 3, 4, 3, 3, 3, 3], + [1, 1, 0, 4, 0, 4, 3], + [2, 0, 4, 1, 2, 0, 3], + [3, 1, 1, 3, 2, 2, 3], + [3, 4, 2, 0, 1, 1, 3], + [4, 2, 3, 2, 4, 2, 3], + [0, 0, 0, 2, 2, 1, 4], + [0, 4, 1, 1, 4, 4, 4], + [1, 1, 2, 1, 3, 2, 4], + [2, 2, 3, 3, 1, 4, 4], + [3, 3, 4, 4, 4, 0, 4], + [4, 0, 1, 0, 0, 3, 4]] + +def ca_37_2_4_6(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_37_2_4_6 + sage: C = ca_37_2_4_6() + sage: is_covering_array(C,2,6) + True + + """ + return [[0, 0, 1, 0], + [0, 0, 2, 1], + [0, 1, 0, 2], + [0, 2, 0, 5], + [0, 3, 3, 3], + [0, 4, 4, 4], + [0, 5, 5, 5], + [1, 0, 0, 4], + [1, 1, 1, 5], + [1, 2, 3, 1], + [1, 3, 4, 0], + [1, 4, 5, 3], + [1, 5, 2, 2], + [2, 0, 0, 3], + [2, 1, 4, 1], + [2, 2, 5, 4], + [2, 3, 1, 2], + [2, 4, 2, 5], + [2, 5, 3, 0], + [3, 0, 5, 2], + [3, 1, 3, 4], + [3, 2, 2, 0], + [3, 3, 0, 5], + [3, 4, 1, 1], + [3, 5, 4, 3], + [4, 0, 3, 5], + [4, 1, 2, 3], + [4, 2, 4, 2], + [4, 3, 5, 1], + [4, 4, 0, 0], + [4, 5, 1, 4], + [5, 0, 4, 5], + [5, 1, 5, 0], + [5, 2, 1, 3], + [5, 3, 2, 4], + [5, 4, 3, 2], + [5, 5, 0, 1]] + +def ca_39_2_5_6(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_39_2_5_6 + sage: C = ca_39_2_5_6() + sage: is_covering_array(C,2,6) + True + + """ + return [[0, 0, 1, 1, 0], + [1, 5, 2, 2, 0], + [2, 4, 5, 4, 0], + [3, 2, 0, 3, 0], + [4, 3, 4, 5, 0], + [5, 1, 3, 0, 0], + [0, 4, 4, 3, 1], + [1, 3, 5, 0, 1], + [2, 2, 1, 2, 1], + [3, 0, 3, 5, 1], + [4, 1, 2, 1, 1], + [5, 5, 0, 4, 1], + [0, 5, 5, 5, 2], + [1, 1, 1, 3, 2], + [2, 3, 0, 1, 2], + [3, 4, 2, 0, 2], + [4, 2, 3, 4, 2], + [5, 0, 4, 2, 2], + [0, 1, 0, 4, 3], + [0, 3, 3, 2, 3], + [1, 0, 2, 4, 3], + [2, 2, 4, 0, 3], + [3, 5, 4, 1, 3], + [4, 0, 5, 3, 3], + [5, 4, 1, 5, 3], + [0, 0, 0, 0, 4], + [1, 2, 0, 5, 4], + [1, 4, 3, 1, 4], + [2, 1, 4, 4, 4], + [3, 1, 5, 2, 4], + [4, 5, 1, 0, 4], + [5, 3, 2, 3, 4], + [0, 2, 2, 0, 5], + [1, 1, 4, 5, 5], + [2, 0, 2, 5, 5], + [2, 5, 3, 3, 5], + [3, 3, 1, 4, 5], + [4, 4, 0, 2, 5], + [5, 2, 5, 1, 5]] + +def ca_41_2_6_6(): + r""" + Return a CA with the given parameters, This CA is proven to be optimal. + This CA is also uniform. + + Data obtained from https://zenodo.org/records/1476059 + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.database import ca_41_2_6_6 + sage: C = ca_41_2_6_6() + sage: is_covering_array(C,2,6) + True + + """ + return [[0, 0, 0, 0, 0, 0], + [1, 1, 4, 5, 4, 0], + [2, 3, 3, 5, 2, 0], + [3, 0, 2, 3, 3, 0], + [3, 5, 5, 2, 1, 0], + [4, 2, 1, 4, 5, 0], + [5, 4, 4, 1, 1, 0], + [0, 0, 1, 1, 1, 1], + [1, 2, 5, 1, 2, 1], + [2, 4, 4, 3, 5, 1], + [2, 5, 2, 4, 0, 1], + [3, 1, 3, 0, 4, 1], + [4, 4, 0, 5, 3, 1], + [5, 3, 1, 2, 0, 1], + [0, 1, 2, 2, 2, 2], + [1, 3, 1, 3, 4, 2], + [1, 5, 4, 0, 3, 2], + [2, 0, 5, 5, 1, 2], + [3, 3, 0, 1, 5, 2], + [4, 4, 3, 2, 0, 2], + [5, 2, 3, 4, 3, 2], + [0, 2, 3, 3, 1, 3], + [0, 5, 1, 5, 5, 3], + [1, 4, 2, 1, 0, 3], + [2, 2, 0, 2, 4, 3], + [3, 3, 5, 4, 3, 3], + [4, 0, 4, 4, 2, 3], + [5, 1, 5, 0, 5, 3], + [0, 3, 4, 2, 3, 4], + [1, 1, 0, 4, 1, 4], + [2, 2, 2, 0, 5, 4], + [3, 4, 1, 0, 2, 4], + [4, 1, 5, 3, 0, 4], + [4, 5, 3, 1, 4, 4], + [5, 0, 2, 5, 4, 4], + [0, 4, 5, 4, 4, 5], + [1, 0, 3, 2, 5, 5], + [2, 1, 1, 1, 3, 5], + [3, 2, 4, 5, 0, 5], + [4, 3, 2, 0, 1, 5], + [5, 5, 0, 3, 2, 5]] + +# Make dictionary with keys (t, v) and values (N, k) which are the +# smallest N and largest k such that a CA(N; t, k, v) can be made using +# the database. +CA_constructions = { + (2,3) : ((11,5), (12,7), (13,9), (14,10), (15,20)), + (2,4) : ((19,6), (21,7)), + (2,5) : ((29,7),), + (2,6) : ((37,4), (39,5), (41,6)) +} + +# Add this data to the module's doc. +LIST_OF_CA_CONSTRUCTIONS = ", ".join(":func:`CA({},{},{},{}) `".format(N,t,k,v,N,t,k,v) + for (t,v) in CA_constructions for (N,k) in CA_constructions[(t,v)]) + __doc__ = __doc__.format( LIST_OF_OA_CONSTRUCTIONS=LIST_OF_OA_CONSTRUCTIONS, LIST_OF_MOLS_CONSTRUCTIONS=LIST_OF_MOLS_CONSTRUCTIONS, @@ -5041,6 +5486,7 @@ def BIBD_56_11_2(): LIST_OF_DF=LIST_OF_DF, LIST_OF_DM=LIST_OF_DM, LIST_OF_QDM=LIST_OF_QDM, - LIST_OF_EDS=LIST_OF_EDS) -del LIST_OF_OA_CONSTRUCTIONS, LIST_OF_MOLS_CONSTRUCTIONS, LIST_OF_VMT_VECTORS,LIST_OF_DF, LIST_OF_DM, LIST_OF_QDM, LIST_OF_EDS, LIST_OF_BIBD + LIST_OF_EDS=LIST_OF_EDS, + LIST_OF_CA_CONSTRUCTIONS=LIST_OF_CA_CONSTRUCTIONS) +del LIST_OF_OA_CONSTRUCTIONS, LIST_OF_MOLS_CONSTRUCTIONS, LIST_OF_VMT_VECTORS,LIST_OF_DF, LIST_OF_DM, LIST_OF_QDM, LIST_OF_EDS, LIST_OF_BIBD, LIST_OF_CA_CONSTRUCTIONS del PolynomialRing, ZZ, a, From 231b4c765955bef13b5b241380395bc64bbf075c Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 16 Feb 2024 10:59:39 -0500 Subject: [PATCH 06/91] Fixed formatting issues --- src/sage/combinat/designs/covering_array.py | 4 ++++ src/sage/combinat/designs/database.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index c353944531b..a41d1f4d68b 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -55,6 +55,7 @@ CA_relabel = OA_relabel CA_standard_label = OA_standard_label + def truncate_columns(array, k): r""" Return a covering array with `k` columns, obtained by removing excess @@ -96,6 +97,7 @@ def truncate_columns(array, k): result.append(row[:k]) return result + def Kleitman_Spencer_Katona(N): r""" Return a `CA(N; 2, k, 2)` where `k = \binom {N-1}{\lceil \frac{N}{2} \rceil}`. @@ -140,6 +142,7 @@ def Kleitman_Spencer_Katona(N): result.append(S) return(list(map(list, zip(*result)))) + def column_Kleitman_Spencer_Katona(k): r""" Return a covering array with `k` columns using the Kleitman Spencer Katona @@ -176,6 +179,7 @@ def column_Kleitman_Spencer_Katona(k): break return truncate_columns(Kleitman_Spencer_Katona(N), k) + def covering_array(strength, number_columns, levels): r""" Build a `CA(N; t, k, v)` using direct constructions, where `N` is the diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index 1e87ebac538..7f15c84861c 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -5035,6 +5035,7 @@ def BIBD_56_11_2(): k, ', '.join('`{}`'.format(q) for q in sorted(EDS[k]) if EDS[k][q] is not False)) for k in sorted(EDS)) + def ca_11_2_5_3(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5062,6 +5063,7 @@ def ca_11_2_5_3(): [2, 1, 1, 1, 1], [2, 2, 0, 0, 0]] + def ca_12_2_7_3(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5090,6 +5092,7 @@ def ca_12_2_7_3(): [2, 2, 0, 0, 2, 1, 1], [2, 2, 2, 1, 0, 0, 0]] + def ca_13_2_9_3(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5119,6 +5122,7 @@ def ca_13_2_9_3(): [2, 2, 0, 1, 2, 1, 2, 2, 1], [2, 2, 1, 0, 0, 2, 1, 1, 2]] + def ca_14_2_10_3(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5149,6 +5153,7 @@ def ca_14_2_10_3(): [2, 2, 1, 0, 2, 1, 0, 0, 0, 1], [2, 2, 1, 1, 0, 0, 2, 1, 1, 0]] + def ca_15_2_20_3(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5180,6 +5185,7 @@ def ca_15_2_20_3(): [2, 1, 2, 1, 0, 1, 2, 2, 1, 1, 2, 0, 2, 1, 0, 0, 1, 2, 0, 0], [2, 2, 1, 1, 1, 1, 0, 1, 0, 0, 2, 2, 1, 2, 2, 1, 0, 1, 0, 2]] + def ca_19_2_6_4(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5215,6 +5221,7 @@ def ca_19_2_6_4(): [3, 2, 2, 2, 1, 1], [3, 3, 0, 0, 2, 2]] + def ca_21_2_7_4(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5253,6 +5260,7 @@ def ca_21_2_7_4(): [3, 3, 0, 1, 0, 2, 3], [3, 3, 3, 3, 2, 0, 2]] + def ca_29_2_7_5(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5298,6 +5306,7 @@ def ca_29_2_7_5(): [3, 3, 4, 4, 4, 0, 4], [4, 0, 1, 0, 0, 3, 4]] + def ca_37_2_4_6(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5351,6 +5360,7 @@ def ca_37_2_4_6(): [5, 4, 3, 2], [5, 5, 0, 1]] + def ca_39_2_5_6(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5406,6 +5416,7 @@ def ca_39_2_5_6(): [4, 4, 0, 2, 5], [5, 2, 5, 1, 5]] + def ca_41_2_6_6(): r""" Return a CA with the given parameters, This CA is proven to be optimal. @@ -5464,6 +5475,7 @@ def ca_41_2_6_6(): [4, 3, 2, 0, 1, 5], [5, 5, 0, 3, 2, 5]] + # Make dictionary with keys (t, v) and values (N, k) which are the # smallest N and largest k such that a CA(N; t, k, v) can be made using # the database. @@ -5478,6 +5490,7 @@ def ca_41_2_6_6(): LIST_OF_CA_CONSTRUCTIONS = ", ".join(":func:`CA({},{},{},{}) `".format(N,t,k,v,N,t,k,v) for (t,v) in CA_constructions for (N,k) in CA_constructions[(t,v)]) + __doc__ = __doc__.format( LIST_OF_OA_CONSTRUCTIONS=LIST_OF_OA_CONSTRUCTIONS, LIST_OF_MOLS_CONSTRUCTIONS=LIST_OF_MOLS_CONSTRUCTIONS, From eb849d5e6b7e78f4615a6f622261b031dc435fc3 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 16 Feb 2024 11:05:03 -0500 Subject: [PATCH 07/91] Formatting issues part 2 --- src/sage/combinat/designs/covering_array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index a41d1f4d68b..045965f9b77 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -240,4 +240,4 @@ def covering_array(strength, number_columns, levels): else: print("No direct construction known and/or implemented for a CA(N; {}, {}, {})".format( strength, number_columns, levels)) - return \ No newline at end of file + return From 327eaf5595f39b63949ae75030400eab7d8a93ba Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 11 Jun 2024 20:04:00 -0400 Subject: [PATCH 08/91] Added an in_database function, it now allows to check the database more generally so it does not need to be changed if things are added. Also edited some functions to produce the same output more efficiently. Fixed some formatting and punctuation errors. --- src/sage/combinat/designs/covering_array.py | 109 ++++++++++++-------- src/sage/combinat/designs/database.py | 22 ++-- 2 files changed, 79 insertions(+), 52 deletions(-) diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index 045965f9b77..0f5e4edf470 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -25,6 +25,7 @@ :meth:`~sage.combinat.designs.covering_array.truncate_columns` | Return an array with `k` columns from a larger one. :meth:`~sage.combinat.designs.covering_array.Kleitman_Spencer_Katona` | Return a `CA(N; 2, k, 2)` using N as input. :meth:`~sage.combinat.designs.covering_array.column_Kleitman_Spencer_Katona` | Return a `CA(N; 2, k, 2)` using k as input. + :meth:`~sage.combinat.designs.covering_array.database_check` | Check if CA can be made from the database of combinatorial designs. :meth:`~sage.combinat.designs.covering_array.covering_array` | Return a `CA` with given parameters. REFERENCES: @@ -92,15 +93,12 @@ def truncate_columns(array, k): raise ValueError("array only has {} columns".format(oldk)) else: - result = [] - for row in array: - result.append(row[:k]) - return result + return [row[:k] for row in array] def Kleitman_Spencer_Katona(N): r""" - Return a `CA(N; 2, k, 2)` where `k = \binom {N-1}{\lceil \frac{N}{2} \rceil}`. + Return a `CA(N; 2, k, 2)` where `k = \binom {N-1}{\lceil N/2 \rceil}`. INPUT: @@ -112,7 +110,7 @@ def Kleitman_Spencer_Katona(N): **Construction** - Take all distinct binary `N`-tuples of weight `\frac{N}{2}` that have a 0 + Take all distinct binary `N`-tuples of weight `N/2` that have a 0 in the first position and place them as columns in an array. EXAMPLES:: @@ -128,24 +126,23 @@ def Kleitman_Spencer_Katona(N): (True, (5, 2, 4, 2)) """ - from math import ceil from itertools import combinations - + from sage.arith.misc import integer_ceil if N < 4: raise ValueError("N must be greater than 3") - result = [] - for p in combinations(range(N-1), ceil(N/2)): + col_list = [] + for p in combinations(range(N-1), integer_ceil(N/2)): S = [0]*N for i in p: S[i] = 1 - result.append(S) - return(list(map(list, zip(*result)))) + col_list.append(S) + return [[col_list[j][i] for j in range(len(col_list))] for i in range(N)] def column_Kleitman_Spencer_Katona(k): r""" - Return a covering array with `k` columns using the Kleitman Spencer Katona + Return a covering array with `k` columns using the Kleitman-Spencer-Katona method. See :func:`~sage.combinat.designs.covering_array.Kleitman_Spencer_Katona` @@ -165,19 +162,60 @@ def column_Kleitman_Spencer_Katona(k): sage: column_Kleitman_Spencer_Katona(25000) Traceback (most recent call last): ... - AssertionError: not implemented for k > 24310 + ValueError: not implemented for k > 24310 """ - assert k <= 24310, "not implemented for k > 24310" + kdict = [(3, 4), (4, 5), (10, 6), (15, 7), (35, 8), (56, 9), + (126, 10), (210, 11), (462, 12), (792, 13), (1716, 14), + (3003, 15), (6435, 16), (11440, 17), (24310, 18)] - kdict = {3:4,4:5,10:6,15:7,35:8,56:9,126:10,210:11,462:12,792:13, - 1716:14,3003:15,6435:16,11440:17,24310:18} + if k > kdict[-1][0]: + raise ValueError("not implemented for k > {}".format(kdict[-1][0])) - for ki in kdict: + for (ki, N) in kdict: if k <= ki: - N = kdict[ki] - break - return truncate_columns(Kleitman_Spencer_Katona(N), k) + return truncate_columns(Kleitman_Spencer_Katona(N), k) + + +def database_check(number_columns, strength, levels): + r""" + Check if the database can be used to build a CA with the given parameters. + If so return the CA, if not return False. + + INPUT: + + - ``strength`` (integer) -- the parameter `t` of the covering array, + such that in any selection of `t` columns of the array, every + `t`-tuple appears at least once. + + - ``levels`` (integer) -- the parameter `v` which is the number of + unique symbols that appear in the covering array. + + - ``number_columns`` (integer) -- the number of columns desired for + the covering array. + + EXAMPLES:: + + sage: from sage.combinat.designs.designs_pyx import is_covering_array + sage: from sage.combinat.designs.covering_array import database_check + sage: C = database_check(6, 2, 3) + sage: is_covering_array(C, parameters=True) + (True, (12, 2, 6, 3)) + sage: database_check(6, 3, 3) + False + + """ + import sage.combinat.designs.database as DB + + if (strength, levels) in DB.CA_constructions: + for i in DB.CA_constructions[(strength, levels)]: + if number_columns <= i[1]: + CA = "ca_{}_{}_{}_{}".format(i[0], strength, i[1], levels) + f = getattr(DB, CA) + return truncate_columns(f(), number_columns) + return False + else: + return False def covering_array(strength, number_columns, levels): @@ -188,8 +226,8 @@ def covering_array(strength, number_columns, levels): INPUT: - ``strength`` (integer) -- the parameter `t` of the covering array, - such that in any selection of `t` columns of the array, every `t` - -tuple appears at least once. + such that in any selection of `t` columns of the array, every + `t`-tuple appears at least once. - ``levels`` (integer) -- the parameter `v` which is the number of unique symbols that appear in the covering array. @@ -210,32 +248,21 @@ def covering_array(strength, number_columns, levels): sage: C3 = covering_array(2, 8, 7) sage: is_covering_array(C3,parameters=True) (True, (49, 2, 8, 7)) - sage: C4 = covering_array(3, 9, 3) - Traceback (most recent call last): - ... - ValueError: CAs and OAs only implemented for strength 2 - sage: C5 = covering_array(2, 50, 7) + sage: C4 = covering_array(2, 50, 7) No direct construction known and/or implemented for a CA(N; 2, 50, 7) """ from sage.combinat.designs.orthogonal_arrays import orthogonal_array - if strength != 2: - raise ValueError("CAs and OAs only implemented for strength 2") - - elif levels == 2: + if levels == 2 and strength == 2: return column_Kleitman_Spencer_Katona(number_columns) - elif 3 <= levels <= 6: - import sage.combinat.designs.database as DB - for i in DB.CA_constructions[(strength, levels)]: - if number_columns <= i[1]: - CA = "ca_{}_{}_{}_{}".format(i[0], strength, i[1], levels) - f = getattr(DB, CA) - return truncate_columns(f(), number_columns) + in_database = database_check(number_columns, strength, levels) + if in_database: + return in_database - elif orthogonal_array(number_columns, levels, existence=True): - return orthogonal_array(number_columns, levels) + if orthogonal_array(number_columns, levels, strength, existence=True) == True: + return orthogonal_array(number_columns, levels, strength) else: print("No direct construction known and/or implemented for a CA(N; {}, {}, {})".format( diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index 7f15c84861c..6fa69f8751e 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -5038,7 +5038,7 @@ def BIBD_56_11_2(): def ca_11_2_5_3(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5066,7 +5066,7 @@ def ca_11_2_5_3(): def ca_12_2_7_3(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5095,7 +5095,7 @@ def ca_12_2_7_3(): def ca_13_2_9_3(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5125,7 +5125,7 @@ def ca_13_2_9_3(): def ca_14_2_10_3(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5156,7 +5156,7 @@ def ca_14_2_10_3(): def ca_15_2_20_3(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from [Nur2004]_ @@ -5188,7 +5188,7 @@ def ca_15_2_20_3(): def ca_19_2_6_4(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5224,7 +5224,7 @@ def ca_19_2_6_4(): def ca_21_2_7_4(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. This CA is also uniform. Data obtained from https://zenodo.org/records/1476059 @@ -5263,7 +5263,7 @@ def ca_21_2_7_4(): def ca_29_2_7_5(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5309,7 +5309,7 @@ def ca_29_2_7_5(): def ca_37_2_4_6(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5363,7 +5363,7 @@ def ca_37_2_4_6(): def ca_39_2_5_6(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. Data obtained from https://zenodo.org/records/1476059 @@ -5419,7 +5419,7 @@ def ca_39_2_5_6(): def ca_41_2_6_6(): r""" - Return a CA with the given parameters, This CA is proven to be optimal. + Return a CA with the given parameters. This CA is proven to be optimal. This CA is also uniform. Data obtained from https://zenodo.org/records/1476059 From 224e30c1ede5de6e26ba9cc747414073bb4005f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 1 Jul 2024 20:57:15 +0200 Subject: [PATCH 09/91] some fixes for ruff code C41 (about loops and iteration) --- src/sage/combinat/specht_module.py | 6 ++--- src/sage/env.py | 6 ++--- .../hyperplane_arrangement/arrangement.py | 10 ++++---- src/sage/graphs/generators/smallgraphs.py | 6 ++--- src/sage/graphs/schnyder.py | 2 +- src/sage/knots/link.py | 4 ++-- src/sage/matroids/matroids_plot_helpers.py | 24 +++++++++---------- src/sage/rings/lazy_series.py | 4 ++-- src/sage/rings/number_field/galois_group.py | 5 ++-- .../rings/valuation/augmented_valuation.py | 2 +- src/sage/tensor/modules/comp.py | 20 ++++++++-------- src/sage/tensor/modules/free_module_tensor.py | 2 +- 12 files changed, 45 insertions(+), 46 deletions(-) diff --git a/src/sage/combinat/specht_module.py b/src/sage/combinat/specht_module.py index 5b8462754ef..9e8b0301020 100644 --- a/src/sage/combinat/specht_module.py +++ b/src/sage/combinat/specht_module.py @@ -920,9 +920,9 @@ def intrinsic_arrangement(self, base_ring=None): G = self._semigroup def t(i, j): - ret = [i for i in range(1, SGA.n+1)] - ret[i-1] = j - ret[j-1] = i + ret = list(range(1, SGA.n + 1)) + ret[i - 1] = j + ret[j - 1] = i return SGA(G(ret)) # Construct the hyperplanes diff --git a/src/sage/env.py b/src/sage/env.py index 722649ab3da..7d4ce090fc2 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -432,9 +432,9 @@ def cython_aliases(required_modules=None, else: continue aliases["ECL_CFLAGS"] = list(filter(lambda s: not s.startswith('-I'), ecl_cflags)) - aliases["ECL_INCDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-I'), ecl_cflags))) - aliases["ECL_LIBDIR"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-L'), ecl_libs))) - aliases["ECL_LIBRARIES"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-l'), ecl_libs))) + aliases["ECL_INCDIR"] = [s[2:] for s in filter(lambda s: s.startswith('-I'), ecl_cflags)] + aliases["ECL_LIBDIR"] = [s[2:] for s in filter(lambda s: s.startswith('-L'), ecl_libs)] + aliases["ECL_LIBRARIES"] = [s[2:] for s in filter(lambda s: s.startswith('-l'), ecl_libs)] aliases["ECL_LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l', '-L')), ecl_libs)) continue else: diff --git a/src/sage/geometry/hyperplane_arrangement/arrangement.py b/src/sage/geometry/hyperplane_arrangement/arrangement.py index 533f7ac1151..aa249a5d32f 100644 --- a/src/sage/geometry/hyperplane_arrangement/arrangement.py +++ b/src/sage/geometry/hyperplane_arrangement/arrangement.py @@ -1850,7 +1850,7 @@ def face_vector(self): return v @cached_method - def _parallel_hyperplanes(self): + def _parallel_hyperplanes(self) -> tuple: """ Return the hyperplanes grouped into parallel sets. @@ -1887,7 +1887,7 @@ def _parallel_hyperplanes(self): (Hyperplane t0 + 0*t1 - t2 + 0, (1, 0, -1), 0))) """ V = self.parent().ambient_space() - parallels = dict() + parallels = {} for hyperplane in self: through_origin = V([list(hyperplane.A()), 0]).primitive(signed=False) parallel_planes = parallels.get(through_origin, []) @@ -1895,9 +1895,9 @@ def _parallel_hyperplanes(self): b = hyperplane.b() * (A / hyperplane.A()) parallel_planes.append([b, (hyperplane, A, b)]) parallels[through_origin] = parallel_planes - parallels = [tuple(tuple(hyperplane[1] - for hyperplane in sorted(parallels[key]))) - for key in parallels.keys()] + parallels = [tuple(hyperplane[1] + for hyperplane in sorted(parallels[key])) + for key in parallels] return tuple(sorted(parallels)) def vertices(self, exclude_sandwiched=False): diff --git a/src/sage/graphs/generators/smallgraphs.py b/src/sage/graphs/generators/smallgraphs.py index 50b1905b7b0..7facb07d2e2 100644 --- a/src/sage/graphs/generators/smallgraphs.py +++ b/src/sage/graphs/generators/smallgraphs.py @@ -2953,7 +2953,7 @@ def GritsenkoGraph(): (33, 49), (33, 51), (33, 57), (33, 61)] # use the union of the orbits of a on the edges return Graph(reduce(lambda x, y: x + y, - map(lambda o: a.orbit(o, action='OnSets'), edges)), + (a.orbit(o, action='OnSets') for o in edges)), format='list_of_edges', name="Gritsenko strongly regular graph") @@ -4738,7 +4738,7 @@ def _EllipticLinesProjectivePlaneScheme(k): gp = libgap.Action(g, libgap.Orbit(g, l, libgap.OnLines), libgap.OnLines) orbitals = gp.Orbits(list(product(gp.Orbit(1), gp.Orbit(1))), libgap.OnTuples) - mats = map(lambda o: [(int(x[0]) - 1, int(x[1]) - 1) for x in o], orbitals) + mats = ([(int(x[0]) - 1, int(x[1]) - 1) for x in o] for o in orbitals) return [matrix((q * (q - 1)) // 2, lambda i, j: 1 if (i, j) in x else 0) for x in mats] @@ -4939,7 +4939,7 @@ def JankoKharaghaniTonchevGraph(): 301, 304, 308, 309, 310, 312, 313, 314, 316, 317, 318) Gamma = Graph(multiedges=False, name='Janko-Kharaghani-Tonchev') for i, b in ((1, B1), (163, B163)): - for j in map(lambda x: x[0], st.OrbitsDomain(b)): + for j in (x[0] for x in st.OrbitsDomain(b)): Gamma.add_edges(map(tuple, G.Orbit(libgap.Set([i, j]), libgap.OnSets))) Gamma.relabel(range(Gamma.order())) return Gamma diff --git a/src/sage/graphs/schnyder.py b/src/sage/graphs/schnyder.py index b22ab6d3302..b699069fda0 100644 --- a/src/sage/graphs/schnyder.py +++ b/src/sage/graphs/schnyder.py @@ -516,7 +516,7 @@ def _compute_coordinates(g, x): for v in g.vertices(sort=False): if v not in [t1.label, t2.label, t3.label]: # Computing coordinates for v - r = list((0, 0, 0)) + r = [0, 0, 0] for i in [0, 1, 2]: # Computing size of region i: diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py index 7470d8c2837..168aecb7fe5 100644 --- a/src/sage/knots/link.py +++ b/src/sage/knots/link.py @@ -4001,7 +4001,7 @@ def _knotinfo_matching_list(self): Sn = KnotInfoSeries(cr, is_knot, False) la = Sa.lower_list(oriented=True, comp=co, det=det, homfly=Hp) ln = Sn.lower_list(oriented=True, comp=co, det=det, homfly=Hp) - l = sorted(list(set(la + ln))) + l = sorted(set(la + ln)) br = self.braid() br_ind = br.strands() @@ -4418,7 +4418,7 @@ def answer_list(l): if not l[0].is_knot(): S = l[0].series(oriented=True) - if set(list(S)) == set(l): + if set(S) == set(l): return answer_unori(S) raise NotImplementedError('this link cannot be uniquely determined%s' % non_unique_hint) diff --git a/src/sage/matroids/matroids_plot_helpers.py b/src/sage/matroids/matroids_plot_helpers.py index 450c56ac049..f5d173beb77 100644 --- a/src/sage/matroids/matroids_plot_helpers.py +++ b/src/sage/matroids/matroids_plot_helpers.py @@ -172,10 +172,11 @@ def it(M, B1, nB1, lps): cc = interval*j pts[i[j-1]] = (cc*pt1[0]+(1-cc)*pt2[0], cc*pt1[1]+(1-cc)*pt2[1]) trilines = [list(set(x)) for x in lines if len(x) >= 3] - curvedlines = [list(set(list(x)).difference(set(lps))) - for x in M.flats(2) if set(list(x)) not in trilines if - len(list(x)) >= 3] - nontripts = [i for i in nB1 if i not in pts.keys()] + set_lps = set(lps) + curvedlines = [list(sx.difference(set_lps)) + for x in M.flats(2) if (sx := set(x)) not in trilines + and len(list(x)) >= 3] + nontripts = [i for i in nB1 if i not in pts] return pts, trilines, nontripts, curvedlines @@ -211,12 +212,12 @@ def trigrid(tripts): This method does NOT do any checks. """ pairs = [[0, 1], [1, 2], [0, 2]] - cpt = list((float(tripts[0][0]+tripts[1][0]+tripts[2][0])/3, - float(tripts[0][1]+tripts[1][1]+tripts[2][1])/3)) + cpt = [float(tripts[0][0] + tripts[1][0] + tripts[2][0]) / 3, + float(tripts[0][1] + tripts[1][1] + tripts[2][1]) / 3] grid = [cpt] - for p in pairs: - pt = list((float(tripts[p[0]][0]+tripts[p[1]][0]+cpt[0])/3, - float(tripts[p[0]][1]+tripts[p[1]][1]+cpt[1])/3)) + for p, q in pairs: + pt = [float(tripts[p][0] + tripts[q][0] + cpt[0]) / 3, + float(tripts[p][1] + tripts[q][1] + cpt[1]) / 3] grid.append(pt) return grid @@ -867,9 +868,8 @@ def geomrep(M1, B1=None, lineorders1=None, pd=None, sp=False): trilines.extend(curvedlines) else: pts2 = M._cached_info['plot_positions'] - trilines = [list(set(list(x)).difference(L | P)) - for x in M1.flats(2) - if len(list(x)) >= 3] + trilines = [list(set(x).difference(L | P)) + for x in M1.flats(2) if len(list(x)) >= 3] pl = [list(x) for x in pts2.values()] lims = tracklims([None, None, None, None], [pt[0] for pt in pl], [pt[1] for pt in pl]) diff --git a/src/sage/rings/lazy_series.py b/src/sage/rings/lazy_series.py index 74744c311da..eb40dfcb475 100644 --- a/src/sage/rings/lazy_series.py +++ b/src/sage/rings/lazy_series.py @@ -476,7 +476,7 @@ def coefficients(self, n=None): return lazy_list(coeffs) # flatten out the generator in the multivariate case - return lazy_list(chain.from_iterable(map(lambda coeff: coeff.coefficients(), coeffs))) + return lazy_list(chain.from_iterable((coeff.coefficients() for coeff in coeffs))) if isinstance(self, LazyPowerSeries) and self.parent()._arity == 1: from sage.misc.superseded import deprecation @@ -486,7 +486,7 @@ def coefficients(self, n=None): return list(islice(coeffs, n)) # flatten out the generator in the multivariate case - return list(islice(chain.from_iterable(map(lambda coeff: coeff.coefficients(), coeffs)), n)) + return list(islice(chain.from_iterable((coeff.coefficients() for coeff in coeffs)), n)) def map_coefficients(self, f): r""" diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py index 364abc0f706..45bad4aa3ba 100644 --- a/src/sage/rings/number_field/galois_group.py +++ b/src/sage/rings/number_field/galois_group.py @@ -573,9 +573,8 @@ def _elts(self): """ if self._gc_numbering: # PARI computes all the elements of self anyway, so we might as well store them - return sorted([self(x, check=False) for x in self._pari_data[5]]) - else: - return sorted(list(self.iteration())) + return sorted(self(x, check=False) for x in self._pari_data[5]) + return sorted(self.iteration()) @lazy_attribute def _gens(self): diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index 3d415c6e83c..7b21678b8ab 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -1550,7 +1550,7 @@ def lift_to_key(self, F, check=True): coefficients[-2] %= self.phi() tau = self.value_group().index(self._base_valuation.value_group()) vf = self._mu * tau * F.degree() - ret = self.domain().change_ring(self.domain())([c for c in coefficients])(self.phi()**tau) + ret = self.domain().change_ring(self.domain())(coefficients)(self.phi()**tau) ret = self.simplify(ret, error=vf, force=True) ret = ret.map_coefficients(_lift_to_maximal_precision) assert (ret == self.phi()) == (F == F.parent().gen()) diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py index 6021997c3b0..590a9cbe621 100644 --- a/src/sage/tensor/modules/comp.py +++ b/src/sage/tensor/modules/comp.py @@ -1633,7 +1633,7 @@ def __add__(self, other): if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in other._comp] + ind_list = list(other._comp) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) # list of input parameters @@ -1864,7 +1864,7 @@ def __mul__(self, other): if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in result.non_redundant_index_generator()] + ind_list = list(result.non_redundant_index_generator()) ind_step = max(1, int(len(ind_list)/nproc)) local_list = lol(ind_list, ind_step) # list of input parameters: @@ -1895,7 +1895,7 @@ def paral_mul(a, local_list_ind): if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in self._comp] + ind_list = list(self._comp) ind_step = max(1, int(len(ind_list)/nproc)) local_list = lol(ind_list, ind_step) # list of input parameters: @@ -2392,7 +2392,7 @@ def compprod(a, b): # parallel computation nproc = Parallelism().get('tensor') lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in res.non_redundant_index_generator()] + ind_list = list(res.non_redundant_index_generator()) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) @@ -3595,7 +3595,7 @@ def __add__(self, other): # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in other._comp] + ind_list = list(other._comp) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) # list of input parameters @@ -3649,7 +3649,7 @@ def paral_sum(a, b, local_list_ind): if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in result.non_redundant_index_generator()] + ind_list = list(result.non_redundant_index_generator()) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) # definition of the list of input parameters @@ -3755,7 +3755,7 @@ def __mul__(self, other): if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in self._comp] + ind_list = list(self._comp) ind_step = max(1, int(len(ind_list)/nproc)) local_list = lol(ind_list, ind_step) # list of input parameters: @@ -4079,7 +4079,7 @@ def non_redundant_index_generator(self): if ind[isym[k-1]] == imax: return ind[pos] = ind[isym[k-1]] + 1 - if not any([pos in isym for isym in sym]) and not any([pos in isym for isym in antisym]): + if not any(pos in isym for isym in sym) and not any(pos in isym for isym in antisym): sym.append([pos]) # treat non-symmetrized indices as being symmetrized with themselves while True: yield tuple(ind) @@ -5125,7 +5125,7 @@ def __add__(self, other): # parallel sum lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in other._comp] + ind_list = list(other._comp) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) # definition of the list of input parameters @@ -5423,7 +5423,7 @@ def __add__(self, other): if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in other._comp] + ind_list = list(other._comp) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) # list of input parameters diff --git a/src/sage/tensor/modules/free_module_tensor.py b/src/sage/tensor/modules/free_module_tensor.py index 5dbc661fa53..fb25fe53e40 100644 --- a/src/sage/tensor/modules/free_module_tensor.py +++ b/src/sage/tensor/modules/free_module_tensor.py @@ -1125,7 +1125,7 @@ class :class:`~sage.tensor.modules.comp.Components` if nproc != 1: # Parallel computation lol = lambda lst, sz: [lst[i:i+sz] for i in range(0, len(lst), sz)] - ind_list = [ind for ind in new_comp.non_redundant_index_generator()] + ind_list = list(new_comp.non_redundant_index_generator()) ind_step = max(1, int(len(ind_list)/nproc/2)) local_list = lol(ind_list, ind_step) # list of input parameters From 704c0fc3de95c05a32476b84dab614390ad84f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 2 Jul 2024 21:12:12 +0200 Subject: [PATCH 10/91] suggested details and tentative improvement --- src/sage/geometry/hyperplane_arrangement/arrangement.py | 7 +++---- src/sage/matroids/matroids_plot_helpers.py | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/geometry/hyperplane_arrangement/arrangement.py b/src/sage/geometry/hyperplane_arrangement/arrangement.py index aa249a5d32f..c83b29b59f6 100644 --- a/src/sage/geometry/hyperplane_arrangement/arrangement.py +++ b/src/sage/geometry/hyperplane_arrangement/arrangement.py @@ -1895,10 +1895,9 @@ def _parallel_hyperplanes(self) -> tuple: b = hyperplane.b() * (A / hyperplane.A()) parallel_planes.append([b, (hyperplane, A, b)]) parallels[through_origin] = parallel_planes - parallels = [tuple(hyperplane[1] - for hyperplane in sorted(parallels[key])) - for key in parallels] - return tuple(sorted(parallels)) + parallels = sorted(tuple(hyperplane[1] for hyperplane in sorted(value)) + for key, value in parallels.items()) + return tuple(parallels) def vertices(self, exclude_sandwiched=False): """ diff --git a/src/sage/matroids/matroids_plot_helpers.py b/src/sage/matroids/matroids_plot_helpers.py index f5d173beb77..e358cc84b66 100644 --- a/src/sage/matroids/matroids_plot_helpers.py +++ b/src/sage/matroids/matroids_plot_helpers.py @@ -171,12 +171,13 @@ def it(M, B1, nB1, lps): # loop over L1,L2,L3 cc = interval*j pts[i[j-1]] = (cc*pt1[0]+(1-cc)*pt2[0], cc*pt1[1]+(1-cc)*pt2[1]) - trilines = [list(set(x)) for x in lines if len(x) >= 3] + trilines = [set(x) for x in lines if len(x) >= 3] set_lps = set(lps) curvedlines = [list(sx.difference(set_lps)) for x in M.flats(2) if (sx := set(x)) not in trilines and len(list(x)) >= 3] nontripts = [i for i in nB1 if i not in pts] + trilines = [list(s) for s in trilines] return pts, trilines, nontripts, curvedlines From 76752abca85ae84b3b04b29d5102217e76ee33f8 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Tue, 2 Jul 2024 14:55:26 -0500 Subject: [PATCH 11/91] Lattes to curve function --- .../arithmetic_dynamics/projective_ds.py | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index d44535ecdb4..c5fecab069c 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -111,6 +111,8 @@ class initialization directly. from sage.schemes.projective.projective_space import ProjectiveSpace, is_ProjectiveSpace from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective from sage.structure.element import get_coercion_model +from sage.schemes.elliptic_curves.constructor import EllipticCurve + lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal') @@ -6838,6 +6840,121 @@ def is_Lattes(self): r_lattes_cases = [[2, 2, 2, 2], [3, 3, 3], [2, 4, 4], [2, 3, 6]] r_vals = sorted([val for val in r.values() if val != 1]) return r_vals in r_lattes_cases + + def Lattes_to_curve(f,return_conjugation = False): + r""" + Finds a Short Weierstrass Model Elliptic curve of self + + self assumed to be Lattes map and not in charateristic 2 or 3 + + INPUT: `return_conjugation`` -- (default: ``False``) if ``True``, then + return the conjugation that moves self to a map that comes from a + Short Weierstrass Model Elliptic curve + + OUTPUT: a Short Weierstrass Model Elliptic curve which is isogenous to + the Elliptic curve of f, If ``return_conjugation`` is ``True`` + then also returns conjugation as a matrix + + EXAMPLES: + + sage: f = P.Lattes_map(EllipticCurve([0, 0, 0, 10, 2]), 2) + sage: Lattes_to_curve(f) + Elliptic Curve defined by y^2 = x^3 + 10*x + 2 over Rational Field + + :: + + sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) + sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) + sage: F = F.conjugate(M) + sage: Lattes_to_curve(F,return_conjugation = True) + ( + Elliptic Curve defined by y^2 = x^3 - 35/16*x + 111/32 over Rational Field, + + [-1/8 -7/4] + [ 1/2 -1] + ) + + :: + + sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) + sage: L. = CyclotomicField(4) + sage: M = Matrix([[i, 0], [0, -i]]) + sage: f.conjugate(M) + sage: Lattes_to_curve(f,True) + ( + Elliptic Curve defined by y^2 = x^3 + 47/48*x + 1529/864 over Rational Field, + + [ 1 5/12] + [ 0 1] + ) + + """ + #Must be NumberField and not QQbar to allow x^(n^2) to be calculated + from sage.rings.qqbar import QQbar + if f.base_ring() not in NumberFields() and f.base_ring() not in QQbar: + raise NotImplementedError("Base ring must be a number field") + + #The Complex case is hard to implement and needs to be done later + if sqrt(f.degree()) != int(sqrt(f.degree())): + raise NotImplementedError("Map is not Lattes or is Complex Lattes") + + + d = f.degree() + n = int(sqrt(f.degree())) + + #Creating a Symbolic Lattes map f_sym from a short Elliptic curve + R = PolynomialRing(QQ,6,"a,b,u,v,w,t") + a,b,u,v,w,t = R.gens() + E_sym = EllipticCurve([a,b]) + P = ProjectiveSpace(QQ,1,"x,y") + x,y = P.gens() + f_sym = P.Lattes_map(E_sym, n) + + # Conjugating f_sym map to have the right form so we can solve for the conjugating matrix later + m=matrix(R,2,[u,v,t,w]) + f_sym = f_sym.conjugate(m) + f_sym.scale_by(u*w - v*t) + F_sym = f_sym.dehomogenize(1) + + #extracting the base variables to do term by term matching + P = ProjectiveSpace(QQ,1,"x,y") + x,y = P.gens() + f.scale_by(1/f[0].coefficient(x^(n^2))) + F = f.dehomogenize(1) + x = F[0].parent().gen(0) + z = F_sym[0].parent().gen(0) + + #Creating a set of equations, eq, from term by term matching + eq = [u*w-t*v - 1] # setting determinant equal to 1 to receive affine transformations only + for j in range(2): + if j == 0: + g = F[0].numerator() + g_sym = F_sym[0].numerator() + else: + g = F[0].denominator() + g_sym = F_sym[0].denominator() + for i in range(d+1): + eq += [g.coefficient({x:i}) - g_sym.coefficient({z:i})] + + #Solving the equations + I = R.ideal(eq) + pts = I.variety() + assert(len(pts)==1) + a = pts[0]['a'] + b = pts[0]['b'] + u = pts[0]['u'] + v = pts[0]['v'] + t = pts[0]['t'] + w = pts[0]['w'] + + #creating our end products + E = EllipticCurve([a,b]) + + if return_conjugation == True: + M = matrix(QQ,2,2,[u,v,t,w]) + return (E , M) + else: + return E class DynamicalSystem_projective_field(DynamicalSystem_projective, From 44046c0554ce5e20ef147b19dfe3576afca79c18 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Wed, 3 Jul 2024 13:09:26 -0500 Subject: [PATCH 12/91] Fixing Doctest problems --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 7c58ac4ddd1..ce0e20b0813 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6854,16 +6854,18 @@ def Lattes_to_curve(f,return_conjugation = False): EXAMPLES: + sage: P. = ProjectiveSpace(QQ, 1) sage: f = P.Lattes_map(EllipticCurve([0, 0, 0, 10, 2]), 2) sage: Lattes_to_curve(f) Elliptic Curve defined by y^2 = x^3 + 10*x + 2 over Rational Field :: + sage: P. = ProjectiveSpace(QQ, 1) sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) - sage: F = F.conjugate(M) - sage: Lattes_to_curve(F,return_conjugation = True) + sage: f = f.conjugate(M) + sage: Lattes_to_curve(f,return_conjugation = True) ( Elliptic Curve defined by y^2 = x^3 - 35/16*x + 111/32 over Rational Field, @@ -6873,6 +6875,7 @@ def Lattes_to_curve(f,return_conjugation = False): :: + sage: P. = ProjectiveSpace(QQ, 1) sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) sage: L. = CyclotomicField(4) sage: M = Matrix([[i, 0], [0, -i]]) @@ -6947,7 +6950,7 @@ def Lattes_to_curve(f,return_conjugation = False): #creating our end products E = EllipticCurve([a,b]) - if return_conjugation == True: + if return_conjugation: M = matrix(QQ,2,2,[u,v,t,w]) return (E , M) else: From 247986bbefbf9be5ad0ef5cb7df34e66f829c5aa Mon Sep 17 00:00:00 2001 From: vboxuser Date: Wed, 3 Jul 2024 13:20:36 -0500 Subject: [PATCH 13/91] Removed changes not relevant to this ticket --- .../dynamics/arithmetic_dynamics/projective_ds.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index ce0e20b0813..944889f6185 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -8557,14 +8557,6 @@ def normal_form(self, return_conjugation=False): To: Finite Field in z2 of size 3^2 Defn: 1 |--> 1 - Fixes issue 38012 by not forcing univariate polynomial to be univariate:: - - sage: R. = PolynomialRing(QQ) - sage: f = DynamicalSystem_affine(z^2 + z + 1).homogenize(1) - sage: f.normal_form() - Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x0 : x1) to - (x0^2 + 5/4*x1^2 : x1^2) """ # defines the field of fixed points if self.codomain().dimension_relative() != 1: @@ -8593,8 +8585,7 @@ def normal_form(self, return_conjugation=False): #we find one and not go all the way to the splitting field i = 0 if G.degree() != 0: - if is_MPolynomialRing(G.parent()): - G = G.polynomial(G.variable(0)) + G = G.polynomial(G.variable(0)) else: #no other fixed points raise NotImplementedError("map is not a polynomial") From bc2cc02cc2f0b9d25a33f9cfca7c77838425d617 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Wed, 3 Jul 2024 14:29:01 -0500 Subject: [PATCH 14/91] Reworking the code so that it actually runs in python not just in notebook --- .../arithmetic_dynamics/projective_ds.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 944889f6185..e2536f875f8 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6838,7 +6838,7 @@ def is_Lattes(self): r_vals = sorted([val for val in r.values() if val != 1]) return r_vals in r_lattes_cases - def Lattes_to_curve(f,return_conjugation = False): + def Lattes_to_curve(self,return_conjugation = False): r""" Finds a Short Weierstrass Model Elliptic curve of self @@ -6849,14 +6849,14 @@ def Lattes_to_curve(f,return_conjugation = False): Short Weierstrass Model Elliptic curve OUTPUT: a Short Weierstrass Model Elliptic curve which is isogenous to - the Elliptic curve of f, If ``return_conjugation`` is ``True`` + the Elliptic curve of 'self', If ``return_conjugation`` is ``True`` then also returns conjugation as a matrix EXAMPLES: sage: P. = ProjectiveSpace(QQ, 1) sage: f = P.Lattes_map(EllipticCurve([0, 0, 0, 10, 2]), 2) - sage: Lattes_to_curve(f) + sage: f.Lattes_to_curve() Elliptic Curve defined by y^2 = x^3 + 10*x + 2 over Rational Field :: @@ -6865,7 +6865,7 @@ def Lattes_to_curve(f,return_conjugation = False): sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) sage: f = f.conjugate(M) - sage: Lattes_to_curve(f,return_conjugation = True) + sage: f.Lattes_to_curve(return_conjugation = True) ( Elliptic Curve defined by y^2 = x^3 - 35/16*x + 111/32 over Rational Field, @@ -6880,7 +6880,7 @@ def Lattes_to_curve(f,return_conjugation = False): sage: L. = CyclotomicField(4) sage: M = Matrix([[i, 0], [0, -i]]) sage: f.conjugate(M) - sage: Lattes_to_curve(f,True) + sage: f.Lattes_to_curve(True) ( Elliptic Curve defined by y^2 = x^3 + 47/48*x + 1529/864 over Rational Field, @@ -6891,22 +6891,22 @@ def Lattes_to_curve(f,return_conjugation = False): """ #Must be NumberField and not QQbar to allow x^(n^2) to be calculated from sage.rings.qqbar import QQbar - if f.base_ring() not in NumberFields() and f.base_ring() not in QQbar: + if self.base_ring() not in NumberFields() and self.base_ring() not in QQbar: raise NotImplementedError("Base ring must be a number field") #The Complex case is hard to implement and needs to be done later - if sqrt(f.degree()) != int(sqrt(f.degree())): + if sqrt(self.degree()) != int(sqrt(self.degree())): raise NotImplementedError("Map is not Lattes or is Complex Lattes") - d = f.degree() - n = int(sqrt(f.degree())) + d = self.degree() + n = int(sqrt(self.degree())) #Creating a Symbolic Lattes map f_sym from a short Elliptic curve R = PolynomialRing(QQ,6,"a,b,u,v,w,t") a,b,u,v,w,t = R.gens() E_sym = EllipticCurve([a,b]) - P = ProjectiveSpace(QQ,1,"x,y") + P = ProjectiveSpace(R,1,"x,y") x,y = P.gens() f_sym = P.Lattes_map(E_sym, n) @@ -6919,8 +6919,8 @@ def Lattes_to_curve(f,return_conjugation = False): #extracting the base variables to do term by term matching P = ProjectiveSpace(QQ,1,"x,y") x,y = P.gens() - f.scale_by(1/f[0].coefficient(x^(n^2))) - F = f.dehomogenize(1) + self.scale_by(1/self[0].coefficient(x**(n**2))) + F = self.dehomogenize(1) x = F[0].parent().gen(0) z = F_sym[0].parent().gen(0) From c8e9d17e935e430d3484a0e00c5003fd48cef393 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Fri, 5 Jul 2024 16:13:57 -0500 Subject: [PATCH 15/91] Changes to handle all rational entry conjugations --- .../arithmetic_dynamics/projective_ds.py | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index e2536f875f8..6e82a6c5ff6 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6862,7 +6862,7 @@ def Lattes_to_curve(self,return_conjugation = False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) + sage: M = matrix(QQ,2,2,[[1,2],[0,2]]) sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) @@ -6875,32 +6875,45 @@ def Lattes_to_curve(self,return_conjugation = False): :: - sage: P. = ProjectiveSpace(QQ, 1) - sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) + sage: P. = ProjectiveSpace(QQ,1) + sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 2, 2]), 2) sage: L. = CyclotomicField(4) - sage: M = Matrix([[i, 0], [0, -i]]) - sage: f.conjugate(M) - sage: f.Lattes_to_curve(True) + sage: M = Matrix([[i,i], [0, -i]]) + sage: f = f.conjugate(M) + sage: f.Lattes_to_curve(true) ( - Elliptic Curve defined by y^2 = x^3 + 47/48*x + 1529/864 over Rational Field, + Elliptic Curve defined by y^2 = x^3 + 95/48*x - 1169/864 over Rational Field, - [ 1 5/12] + [ 1 7/12] [ 0 1] ) + :: + sage: P. = ProjectiveSpace(QQ, 1) + sage: M = matrix(QQ,2,2,[[1,3],[2,1]]) + sage: E = EllipticCurve([1, 1, 1, 2, 3]) + sage: f = P.Lattes_map(E, 3) + sage: f = f.conjugate(M) + sage: f.Lattes_to_curve(return_conjugation = True) + ( + Elliptic Curve defined by y^2 = x^3 + 2971089832419908421490114560/672749994932560009201*x - 136859124978149365523025777492183402676224/17449402268886407318558803753801 over Rational Field, + + [ 1 41/22] + [-2357947691/3228757749504 -2357947691/6457515499008] + ) + """ - #Must be NumberField and not QQbar to allow x^(n^2) to be calculated - from sage.rings.qqbar import QQbar - if self.base_ring() not in NumberFields() and self.base_ring() not in QQbar: + if self.base_ring() not in NumberFields(): raise NotImplementedError("Base ring must be a number field") #The Complex case is hard to implement and needs to be done later if sqrt(self.degree()) != int(sqrt(self.degree())): raise NotImplementedError("Map is not Lattes or is Complex Lattes") - - + + + d = self.degree() - n = int(sqrt(self.degree())) + n = int(sqrt(self.degree()))\ #Creating a Symbolic Lattes map f_sym from a short Elliptic curve R = PolynomialRing(QQ,6,"a,b,u,v,w,t") @@ -6909,7 +6922,7 @@ def Lattes_to_curve(self,return_conjugation = False): P = ProjectiveSpace(R,1,"x,y") x,y = P.gens() f_sym = P.Lattes_map(E_sym, n) - + # Conjugating f_sym map to have the right form so we can solve for the conjugating matrix later m=matrix(R,2,[u,v,t,w]) f_sym = f_sym.conjugate(m) @@ -6919,13 +6932,14 @@ def Lattes_to_curve(self,return_conjugation = False): #extracting the base variables to do term by term matching P = ProjectiveSpace(QQ,1,"x,y") x,y = P.gens() - self.scale_by(1/self[0].coefficient(x**(n**2))) + self.scale_by(1/self[0].lc()) F = self.dehomogenize(1) x = F[0].parent().gen(0) z = F_sym[0].parent().gen(0) #Creating a set of equations, eq, from term by term matching - eq = [u*w-t*v - 1] # setting determinant equal to 1 to receive affine transformations only + #Scales conjugation matrix to have 1 in top left entry original solution wanted det=1 but proved too restrictive + eq = [u-1] for j in range(2): if j == 0: g = F[0].numerator() From 787ae63c485909945d9ed5c583ae38b18b976c88 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Fri, 5 Jul 2024 17:08:50 -0500 Subject: [PATCH 16/91] Passes Doc tests now --- .../arithmetic_dynamics/projective_ds.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 6e82a6c5ff6..86dd4ff24e9 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6850,7 +6850,7 @@ def Lattes_to_curve(self,return_conjugation = False): OUTPUT: a Short Weierstrass Model Elliptic curve which is isogenous to the Elliptic curve of 'self', If ``return_conjugation`` is ``True`` - then also returns conjugation as a matrix + then also returns conjugation of 'self' to short form as a matrix EXAMPLES: @@ -6862,17 +6862,18 @@ def Lattes_to_curve(self,return_conjugation = False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: M = matrix(QQ,2,2,[[1,2],[0,2]]) + sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - Elliptic Curve defined by y^2 = x^3 - 35/16*x + 111/32 over Rational Field, - - [-1/8 -7/4] - [ 1/2 -1] + Elliptic Curve defined by y^2 = x^3 + 2182587088896/282475249*x + 5889333996885639168/4747561509943 over Rational Field, + + [ 1 34/7] + [-2401/124416 2401/62208] ) + :: sage: P. = ProjectiveSpace(QQ,1) @@ -6883,12 +6884,13 @@ def Lattes_to_curve(self,return_conjugation = False): sage: f.Lattes_to_curve(true) ( Elliptic Curve defined by y^2 = x^3 + 95/48*x - 1169/864 over Rational Field, - + [ 1 7/12] [ 0 1] ) :: + sage: P. = ProjectiveSpace(QQ, 1) sage: M = matrix(QQ,2,2,[[1,3],[2,1]]) sage: E = EllipticCurve([1, 1, 1, 2, 3]) @@ -6897,7 +6899,7 @@ def Lattes_to_curve(self,return_conjugation = False): sage: f.Lattes_to_curve(return_conjugation = True) ( Elliptic Curve defined by y^2 = x^3 + 2971089832419908421490114560/672749994932560009201*x - 136859124978149365523025777492183402676224/17449402268886407318558803753801 over Rational Field, - + [ 1 41/22] [-2357947691/3228757749504 -2357947691/6457515499008] ) From 330805fad406975005b5143d9fdcb89341f53eed Mon Sep 17 00:00:00 2001 From: vboxuser Date: Mon, 8 Jul 2024 17:15:31 -0500 Subject: [PATCH 17/91] Updating code to solve some for some conjugations over number fields --- .../arithmetic_dynamics/projective_ds.py | 64 +++++++------------ 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 86dd4ff24e9..12fac0ea9c8 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -109,7 +109,6 @@ class initialization directly. from sage.schemes.projective.projective_space import ProjectiveSpace, ProjectiveSpace_ring from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective from sage.structure.element import get_coercion_model -from sage.schemes.elliptic_curves.constructor import EllipticCurve lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') @@ -5179,7 +5178,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: sage: K = GF(3).algebraic_closure() - sage: P. = ProjectiveSpace(K, 2) + sagxe: P. = ProjectiveSpace(K, 2) sage: f = DynamicalSystem_projective([x^2 + 2*y^2, 4*x*y, z^2]) sage: f.multiplier_spectra(1) # needs sage.rings.number_field [ @@ -6837,7 +6836,7 @@ def is_Lattes(self): r_lattes_cases = [[2, 2, 2, 2], [3, 3, 3], [2, 4, 4], [2, 3, 6]] r_vals = sorted([val for val in r.values() if val != 1]) return r_vals in r_lattes_cases - + def Lattes_to_curve(self,return_conjugation = False): r""" Finds a Short Weierstrass Model Elliptic curve of self @@ -6849,7 +6848,8 @@ def Lattes_to_curve(self,return_conjugation = False): Short Weierstrass Model Elliptic curve OUTPUT: a Short Weierstrass Model Elliptic curve which is isogenous to - the Elliptic curve of 'self', If ``return_conjugation`` is ``True`` + the Elliptic curve of 'self' and the defining polynomial of any required extension, + If ``return_conjugation`` is ``True`` then also returns conjugation of 'self' to short form as a matrix EXAMPLES: @@ -6867,26 +6867,21 @@ def Lattes_to_curve(self,return_conjugation = False): sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - Elliptic Curve defined by y^2 = x^3 + 2182587088896/282475249*x + 5889333996885639168/4747561509943 over Rational Field, - - [ 1 34/7] - [-2401/124416 2401/62208] + [ -7/36*a^2 + 7/12*a + 7/3 -17/18*a^2 + 17/6*a + 34/3] + [ -1/8*a^2 + 1/4*a + 3/2 1/4*a^2 - 1/2*a - 3], Elliptic Curve defined by y^2 = x^3 + (-94/27*a^2+94/9*a+376/9)*x + 12232/243 over Number Field in a with defining polynomial y^3 - 18*y - 30 ) - :: sage: P. = ProjectiveSpace(QQ,1) sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 2, 2]), 2) sage: L. = CyclotomicField(4) - sage: M = Matrix([[i,i], [0, -i]]) + sage: M = Matrix([[1+i,2*i], [0, -i]]) sage: f = f.conjugate(M) - sage: f.Lattes_to_curve(true) + sage: f.Lattes_to_curve(return_conjugation = True) ( - Elliptic Curve defined by y^2 = x^3 + 95/48*x - 1169/864 over Rational Field, - - [ 1 7/12] - [ 0 1] + [ 1 19/24*I + 19/24] + [ 0 1], Elliptic Curve defined by y^2 = x^3 + 95/96*I*x + (-1169/3456*I+1169/3456) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I ) :: @@ -6894,54 +6889,45 @@ def Lattes_to_curve(self,return_conjugation = False): sage: P. = ProjectiveSpace(QQ, 1) sage: M = matrix(QQ,2,2,[[1,3],[2,1]]) sage: E = EllipticCurve([1, 1, 1, 2, 3]) - sage: f = P.Lattes_map(E, 3) + sage: f = P.Lattes_map(E, 2) sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - Elliptic Curve defined by y^2 = x^3 + 2971089832419908421490114560/672749994932560009201*x - 136859124978149365523025777492183402676224/17449402268886407318558803753801 over Rational Field, - - [ 1 41/22] - [-2357947691/3228757749504 -2357947691/6457515499008] + [11/1602*a^2 41/3204*a^2] + [ -2/5*a -1/5*a], Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 ) """ if self.base_ring() not in NumberFields(): raise NotImplementedError("Base ring must be a number field") - #The Complex case is hard to implement and needs to be done later if sqrt(self.degree()) != int(sqrt(self.degree())): raise NotImplementedError("Map is not Lattes or is Complex Lattes") - - - + from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics + from sage.schemes.elliptic_curves.constructor import EllipticCurve d = self.degree() - n = int(sqrt(self.degree()))\ - + n = int(sqrt(self.degree())) #Creating a Symbolic Lattes map f_sym from a short Elliptic curve - R = PolynomialRing(QQ,6,"a,b,u,v,w,t") + R = PolynomialRing(self.base_ring(),6,"a,b,u,v,w,t") a,b,u,v,w,t = R.gens() E_sym = EllipticCurve([a,b]) P = ProjectiveSpace(R,1,"x,y") x,y = P.gens() f_sym = P.Lattes_map(E_sym, n) - # Conjugating f_sym map to have the right form so we can solve for the conjugating matrix later m=matrix(R,2,[u,v,t,w]) f_sym = f_sym.conjugate(m) f_sym.scale_by(u*w - v*t) F_sym = f_sym.dehomogenize(1) - #extracting the base variables to do term by term matching - P = ProjectiveSpace(QQ,1,"x,y") + P = ProjectiveSpace(self.base_ring(),1,"x,y") x,y = P.gens() self.scale_by(1/self[0].lc()) F = self.dehomogenize(1) x = F[0].parent().gen(0) z = F_sym[0].parent().gen(0) - #Creating a set of equations, eq, from term by term matching - #Scales conjugation matrix to have 1 in top left entry original solution wanted det=1 but proved too restrictive - eq = [u-1] + eq = [u*w - v*t-1] for j in range(2): if j == 0: g = F[0].numerator() @@ -6951,28 +6937,24 @@ def Lattes_to_curve(self,return_conjugation = False): g_sym = F_sym[0].denominator() for i in range(d+1): eq += [g.coefficient({x:i}) - g_sym.coefficient({z:i})] - #Solving the equations I = R.ideal(eq) - pts = I.variety() - assert(len(pts)==1) + pts = I.variety(ring=QQbar) a = pts[0]['a'] b = pts[0]['b'] u = pts[0]['u'] v = pts[0]['v'] t = pts[0]['t'] w = pts[0]['w'] - + K,[a,b,u,v,t,w],phi = number_field_elements_from_algebraics([a,b,u,v,t,w]) #creating our end products E = EllipticCurve([a,b]) - if return_conjugation: - M = matrix(QQ,2,2,[u,v,t,w]) - return (E , M) + M = matrix(K,2,2,[u,v,t,w]) + return (M,E) else: return E - class DynamicalSystem_projective_field(DynamicalSystem_projective, SchemeMorphism_polynomial_projective_space_field): From e0fbbb62c55c9767f5c7bdc1908a33658ef7b94a Mon Sep 17 00:00:00 2001 From: vboxuser Date: Tue, 9 Jul 2024 09:58:48 -0500 Subject: [PATCH 18/91] Adding doctest to verify conjugation returns correct result --- .../arithmetic_dynamics/projective_ds.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 12fac0ea9c8..4ee0c113169 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -5178,7 +5178,7 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: sage: K = GF(3).algebraic_closure() - sagxe: P. = ProjectiveSpace(K, 2) + sage: P. = ProjectiveSpace(K, 2) sage: f = DynamicalSystem_projective([x^2 + 2*y^2, 4*x*y, z^2]) sage: f.multiplier_spectra(1) # needs sage.rings.number_field [ @@ -6897,6 +6897,21 @@ def Lattes_to_curve(self,return_conjugation = False): [ -2/5*a -1/5*a], Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 ) + :: + + sage: P. = ProjectiveSpace(QQ , 1) + sage: M = matrix(QQ,2,2,[[1 , 3],[2 , 1]]) + sage: E = EllipticCurve([1, 1, 1, 2, 3]) + sage: f = P.Lattes_map(E , 2) + sage: f = f.conjugate(M) + sage: m,H = f.Lattes_to_curve(true) + sage: J. = ProjectiveSpace(H.base_ring(), 1) + sage: K = J.Lattes_map(H,2) + sage: K = K.conjugate(m) + sage: K.scale_by(f[0].lc()/K[0].lc()) + sage: K == f.change_ring(K.base_ring()) + True + """ if self.base_ring() not in NumberFields(): raise NotImplementedError("Base ring must be a number field") From 7ecc8b7ec5d34dc3e87230afeb66bbd34403935f Mon Sep 17 00:00:00 2001 From: vboxuser Date: Tue, 9 Jul 2024 13:33:52 -0500 Subject: [PATCH 19/91] Trying to get all the formatting errors --- .../arithmetic_dynamics/projective_ds.py | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 4ee0c113169..3ccb6304c12 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6837,19 +6837,18 @@ def is_Lattes(self): r_vals = sorted([val for val in r.values() if val != 1]) return r_vals in r_lattes_cases - def Lattes_to_curve(self,return_conjugation = False): + def Lattes_to_curve(self, return_conjugation=False): r""" Finds a Short Weierstrass Model Elliptic curve of self - self assumed to be Lattes map and not in charateristic 2 or 3 INPUT: `return_conjugation`` -- (default: ``False``) if ``True``, then - return the conjugation that moves self to a map that comes from a + return the conjugation that moves self to a map that comes from a Short Weierstrass Model Elliptic curve OUTPUT: a Short Weierstrass Model Elliptic curve which is isogenous to - the Elliptic curve of 'self' and the defining polynomial of any required extension, - If ``return_conjugation`` is ``True`` + the Elliptic curve of 'self' and the defining polynomial of any required extension, + If ``return_conjugation`` is ``True`` then also returns conjugation of 'self' to short form as a matrix EXAMPLES: @@ -6923,20 +6922,20 @@ def Lattes_to_curve(self,return_conjugation = False): d = self.degree() n = int(sqrt(self.degree())) #Creating a Symbolic Lattes map f_sym from a short Elliptic curve - R = PolynomialRing(self.base_ring(),6,"a,b,u,v,w,t") - a,b,u,v,w,t = R.gens() - E_sym = EllipticCurve([a,b]) - P = ProjectiveSpace(R,1,"x,y") - x,y = P.gens() + R = PolynomialRing(self.base_ring(),6,"a, b, u, v, w, t") + a, b, u, v, w, t = R.gens() + E_sym = EllipticCurve([a, b]) + P = ProjectiveSpace(R,1,"x, y") + x, y = P.gens() f_sym = P.Lattes_map(E_sym, n) # Conjugating f_sym map to have the right form so we can solve for the conjugating matrix later - m=matrix(R,2,[u,v,t,w]) + m=matrix(R, 2, [u, v, t, w]) f_sym = f_sym.conjugate(m) f_sym.scale_by(u*w - v*t) F_sym = f_sym.dehomogenize(1) #extracting the base variables to do term by term matching - P = ProjectiveSpace(self.base_ring(),1,"x,y") - x,y = P.gens() + P = ProjectiveSpace(self.base_ring(), 1, "x, y") + x, y = P.gens() self.scale_by(1/self[0].lc()) F = self.dehomogenize(1) x = F[0].parent().gen(0) @@ -6950,7 +6949,7 @@ def Lattes_to_curve(self,return_conjugation = False): else: g = F[0].denominator() g_sym = F_sym[0].denominator() - for i in range(d+1): + for i in range(d + 1): eq += [g.coefficient({x:i}) - g_sym.coefficient({z:i})] #Solving the equations I = R.ideal(eq) @@ -6961,12 +6960,12 @@ def Lattes_to_curve(self,return_conjugation = False): v = pts[0]['v'] t = pts[0]['t'] w = pts[0]['w'] - K,[a,b,u,v,t,w],phi = number_field_elements_from_algebraics([a,b,u,v,t,w]) + K, [a, b, u, v, t, w], phi = number_field_elements_from_algebraics([a, b, u, v, t, w]) #creating our end products - E = EllipticCurve([a,b]) + E = EllipticCurve([a, b]) if return_conjugation: - M = matrix(K,2,2,[u,v,t,w]) - return (M,E) + M = matrix(K, 2, 2, [u, v, t, w]) + return (M, E) else: return E From 7a109f5d77b2a0fa8507e51af9ced679d09aa1d9 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Wed, 10 Jul 2024 12:00:30 -0500 Subject: [PATCH 20/91] Fixing lint errors --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 3ccb6304c12..eff449c1239 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6851,7 +6851,7 @@ def Lattes_to_curve(self, return_conjugation=False): If ``return_conjugation`` is ``True`` then also returns conjugation of 'self' to short form as a matrix - EXAMPLES: + EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = P.Lattes_map(EllipticCurve([0, 0, 0, 10, 2]), 2) @@ -6866,7 +6866,7 @@ def Lattes_to_curve(self, return_conjugation=False): sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - [ -7/36*a^2 + 7/12*a + 7/3 -17/18*a^2 + 17/6*a + 34/3] + [ -7/36*a^2 + 7/12*a + 7/3 -17/18*a^2 + 17/6*a + 34/3] [ -1/8*a^2 + 1/4*a + 3/2 1/4*a^2 - 1/2*a - 3], Elliptic Curve defined by y^2 = x^3 + (-94/27*a^2+94/9*a+376/9)*x + 12232/243 over Number Field in a with defining polynomial y^3 - 18*y - 30 ) @@ -6879,7 +6879,7 @@ def Lattes_to_curve(self, return_conjugation=False): sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - [ 1 19/24*I + 19/24] + [ 1 19/24*I + 19/24] [ 0 1], Elliptic Curve defined by y^2 = x^3 + 95/96*I*x + (-1169/3456*I+1169/3456) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I ) @@ -6892,7 +6892,7 @@ def Lattes_to_curve(self, return_conjugation=False): sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - [11/1602*a^2 41/3204*a^2] + [11/1602*a^2 41/3204*a^2] [ -2/5*a -1/5*a], Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 ) @@ -6929,7 +6929,7 @@ def Lattes_to_curve(self, return_conjugation=False): x, y = P.gens() f_sym = P.Lattes_map(E_sym, n) # Conjugating f_sym map to have the right form so we can solve for the conjugating matrix later - m=matrix(R, 2, [u, v, t, w]) + m = matrix(R, 2, [u, v, t, w]) f_sym = f_sym.conjugate(m) f_sym.scale_by(u*w - v*t) F_sym = f_sym.dehomogenize(1) From 25e9cb4c2832bbbd27048e0d65580389d9de9064 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Wed, 10 Jul 2024 18:22:25 -0500 Subject: [PATCH 21/91] Lint stuff --- .../arithmetic_dynamics/projective_ds.py | 118 +++++++++--------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index eff449c1239..75c92a17608 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6842,7 +6842,9 @@ def Lattes_to_curve(self, return_conjugation=False): Finds a Short Weierstrass Model Elliptic curve of self self assumed to be Lattes map and not in charateristic 2 or 3 - INPUT: `return_conjugation`` -- (default: ``False``) if ``True``, then + INPUT: + + - `return_conjugation`` -- (default: ``False``) if ``True``, then return the conjugation that moves self to a map that comes from a Short Weierstrass Model Elliptic curve @@ -6853,63 +6855,63 @@ def Lattes_to_curve(self, return_conjugation=False): EXAMPLES:: - sage: P. = ProjectiveSpace(QQ, 1) - sage: f = P.Lattes_map(EllipticCurve([0, 0, 0, 10, 2]), 2) - sage: f.Lattes_to_curve() - Elliptic Curve defined by y^2 = x^3 + 10*x + 2 over Rational Field - - :: - - sage: P. = ProjectiveSpace(QQ, 1) - sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) - sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) - sage: f = f.conjugate(M) - sage: f.Lattes_to_curve(return_conjugation = True) - ( - [ -7/36*a^2 + 7/12*a + 7/3 -17/18*a^2 + 17/6*a + 34/3] - [ -1/8*a^2 + 1/4*a + 3/2 1/4*a^2 - 1/2*a - 3], Elliptic Curve defined by y^2 = x^3 + (-94/27*a^2+94/9*a+376/9)*x + 12232/243 over Number Field in a with defining polynomial y^3 - 18*y - 30 - ) - - :: - - sage: P. = ProjectiveSpace(QQ,1) - sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 2, 2]), 2) - sage: L. = CyclotomicField(4) - sage: M = Matrix([[1+i,2*i], [0, -i]]) - sage: f = f.conjugate(M) - sage: f.Lattes_to_curve(return_conjugation = True) - ( - [ 1 19/24*I + 19/24] - [ 0 1], Elliptic Curve defined by y^2 = x^3 + 95/96*I*x + (-1169/3456*I+1169/3456) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - ) - - :: - - sage: P. = ProjectiveSpace(QQ, 1) - sage: M = matrix(QQ,2,2,[[1,3],[2,1]]) - sage: E = EllipticCurve([1, 1, 1, 2, 3]) - sage: f = P.Lattes_map(E, 2) - sage: f = f.conjugate(M) - sage: f.Lattes_to_curve(return_conjugation = True) - ( - [11/1602*a^2 41/3204*a^2] - [ -2/5*a -1/5*a], Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 - ) - - :: - - sage: P. = ProjectiveSpace(QQ , 1) - sage: M = matrix(QQ,2,2,[[1 , 3],[2 , 1]]) - sage: E = EllipticCurve([1, 1, 1, 2, 3]) - sage: f = P.Lattes_map(E , 2) - sage: f = f.conjugate(M) - sage: m,H = f.Lattes_to_curve(true) - sage: J. = ProjectiveSpace(H.base_ring(), 1) - sage: K = J.Lattes_map(H,2) - sage: K = K.conjugate(m) - sage: K.scale_by(f[0].lc()/K[0].lc()) - sage: K == f.change_ring(K.base_ring()) - True + sage: P. = ProjectiveSpace(QQ, 1) + sage: f = P.Lattes_map(EllipticCurve([0, 0, 0, 10, 2]), 2) + sage: f.Lattes_to_curve() + Elliptic Curve defined by y^2 = x^3 + 10*x + 2 over Rational Field + + :: + + sage: P. = ProjectiveSpace(QQ, 1) + sage: M = matrix(QQ,2,2,[[1,2],[-1,2]]) + sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 1, 2]), 2) + sage: f = f.conjugate(M) + sage: f.Lattes_to_curve(return_conjugation = True) + ( + [ -7/36*a^2 + 7/12*a + 7/3 -17/18*a^2 + 17/6*a + 34/3] + [ -1/8*a^2 + 1/4*a + 3/2 1/4*a^2 - 1/2*a - 3], Elliptic Curve defined by y^2 = x^3 + (-94/27*a^2+94/9*a+376/9)*x + 12232/243 over Number Field in a with defining polynomial y^3 - 18*y - 30 + ) + + :: + + sage: P. = ProjectiveSpace(QQ,1) + sage: f = P.Lattes_map(EllipticCurve([1, 1, 1, 2, 2]), 2) + sage: L. = CyclotomicField(4) + sage: M = Matrix([[1+i,2*i], [0, -i]]) + sage: f = f.conjugate(M) + sage: f.Lattes_to_curve(return_conjugation = True) + ( + [ 1 19/24*I + 19/24] + [ 0 1], Elliptic Curve defined by y^2 = x^3 + 95/96*I*x + (-1169/3456*I+1169/3456) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I + ) + + :: + + sage: P. = ProjectiveSpace(QQ, 1) + sage: M = matrix(QQ,2,2,[[1,3],[2,1]]) + sage: E = EllipticCurve([1, 1, 1, 2, 3]) + sage: f = P.Lattes_map(E, 2) + sage: f = f.conjugate(M) + sage: f.Lattes_to_curve(return_conjugation = True) + ( + [11/1602*a^2 41/3204*a^2] + [ -2/5*a -1/5*a], Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 + ) + + :: + + sage: P. = ProjectiveSpace(QQ , 1) + sage: M = matrix(QQ,2,2,[[1 , 3],[2 , 1]]) + sage: E = EllipticCurve([1, 1, 1, 2, 3]) + sage: f = P.Lattes_map(E , 2) + sage: f = f.conjugate(M) + sage: m,H = f.Lattes_to_curve(true) + sage: J. = ProjectiveSpace(H.base_ring(), 1) + sage: K = J.Lattes_map(H,2) + sage: K = K.conjugate(m) + sage: K.scale_by(f[0].lc()/K[0].lc()) + sage: K == f.change_ring(K.base_ring()) + True """ if self.base_ring() not in NumberFields(): From 54ea9440c35608143b00e60bf9827901d9631010 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Wed, 10 Jul 2024 18:43:13 -0500 Subject: [PATCH 22/91] Lint --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 75c92a17608..e21f90e0a1b 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6844,7 +6844,7 @@ def Lattes_to_curve(self, return_conjugation=False): INPUT: - - `return_conjugation`` -- (default: ``False``) if ``True``, then + `return_conjugation`` -- (default: ``False``) if ``True``, then return the conjugation that moves self to a map that comes from a Short Weierstrass Model Elliptic curve From fe558d2c055f5fac093b988ff69c780f31c5eeea Mon Sep 17 00:00:00 2001 From: vboxuser Date: Tue, 16 Jul 2024 13:05:57 -0500 Subject: [PATCH 23/91] Completed all the needs of the above comment --- .../arithmetic_dynamics/projective_ds.py | 106 +++++++++++++----- 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index e21f90e0a1b..c12bde6ec6f 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -109,7 +109,8 @@ class initialization directly. from sage.schemes.projective.projective_space import ProjectiveSpace, ProjectiveSpace_ring from sage.schemes.projective.projective_subscheme import AlgebraicScheme_subscheme_projective from sage.structure.element import get_coercion_model - +from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics +from sage.schemes.elliptic_curves.constructor import EllipticCurve lazy_import('sage.rings.algebraic_closure_finite_field', 'AlgebraicClosureFiniteField_generic') lazy_import('sage.rings.number_field.number_field_ideal', 'NumberFieldFractionalIdeal') @@ -6837,7 +6838,7 @@ def is_Lattes(self): r_vals = sorted([val for val in r.values() if val != 1]) return r_vals in r_lattes_cases - def Lattes_to_curve(self, return_conjugation=False): + def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): r""" Finds a Short Weierstrass Model Elliptic curve of self self assumed to be Lattes map and not in charateristic 2 or 3 @@ -6847,9 +6848,10 @@ def Lattes_to_curve(self, return_conjugation=False): `return_conjugation`` -- (default: ``False``) if ``True``, then return the conjugation that moves self to a map that comes from a Short Weierstrass Model Elliptic curve + `check_lattes``.-.(default:.``False``) if ``True``, then will ValueError if not Lattes OUTPUT: a Short Weierstrass Model Elliptic curve which is isogenous to - the Elliptic curve of 'self' and the defining polynomial of any required extension, + the Elliptic curve of 'self', If ``return_conjugation`` is ``True`` then also returns conjugation of 'self' to short form as a matrix @@ -6869,7 +6871,9 @@ def Lattes_to_curve(self, return_conjugation=False): sage: f.Lattes_to_curve(return_conjugation = True) ( [ -7/36*a^2 + 7/12*a + 7/3 -17/18*a^2 + 17/6*a + 34/3] - [ -1/8*a^2 + 1/4*a + 3/2 1/4*a^2 - 1/2*a - 3], Elliptic Curve defined by y^2 = x^3 + (-94/27*a^2+94/9*a+376/9)*x + 12232/243 over Number Field in a with defining polynomial y^3 - 18*y - 30 + [ -1/8*a^2 + 1/4*a + 3/2 1/4*a^2 - 1/2*a - 3], + Elliptic Curve defined by y^2 = x^3 + (-94/27*a^2+94/9*a+376/9)*x + + 12232/243 over Number Field in a with defining polynomial y^3 - 18*y - 30 ) :: @@ -6881,8 +6885,10 @@ def Lattes_to_curve(self, return_conjugation=False): sage: f = f.conjugate(M) sage: f.Lattes_to_curve(return_conjugation = True) ( - [ 1 19/24*I + 19/24] - [ 0 1], Elliptic Curve defined by y^2 = x^3 + 95/96*I*x + (-1169/3456*I+1169/3456) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I + [ 1 19/24*a + 19/24] + [ 0 1], + Elliptic Curve defined by y^2 = x^3 + 95/96*a*x + (-1169/3456*a+1169/3456) + over Number Field in a with defining polynomial y^2 + 1 ) :: @@ -6895,7 +6901,9 @@ def Lattes_to_curve(self, return_conjugation=False): sage: f.Lattes_to_curve(return_conjugation = True) ( [11/1602*a^2 41/3204*a^2] - [ -2/5*a -1/5*a], Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 + [ -2/5*a -1/5*a], + Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) + over Number Field in a with defining polynomial y^3 - 267 ) :: @@ -6913,22 +6921,60 @@ def Lattes_to_curve(self, return_conjugation=False): sage: K == f.change_ring(K.base_ring()) True + :: + + sage: P. = ProjectiveSpace(QQ,1) + sage: F = DynamicalSystem_projective([x^4,y^4]) + sage: F.Lattes_to_curve(check_lattes=True) + Traceback (most recent call last): + ... + ValueError: Map is not Lattes + + :: + + sage: P. = ProjectiveSpace(QQbar,1) + sage: F = DynamicalSystem_projective([x^4,y^4]) + sage: F.Lattes_to_curve(check_lattes=True) + Traceback (most recent call last): + ... + NotImplementedError: Base ring must be a number field + + :: + + sage: P. = ProjectiveSpace(QQ,1) + sage: F = DynamicalSystem_projective([x^3,y^3]) + sage: F.Lattes_to_curve(check_lattes=True) + Traceback (most recent call last): + ... + NotImplementedError: Map is not Lattes or is Complex Lattes + + :: + + sage: K.=QuadraticField(2) + sage: P.=ProjectiveSpace(K,1) + sage: E=EllipticCurve([1,x]) + sage: f=P.Lattes_map(E,2) + sage: f.Lattes_to_curve() + Elliptic Curve defined by y^2 = x^3 + x + a + over Number Field in a with defining polynomial y^2 - 2 + """ - if self.base_ring() not in NumberFields(): - raise NotImplementedError("Base ring must be a number field") + if self.base_ring() is not QQbar: + if self.base_ring() not in NumberFields(): + raise NotImplementedError("Base ring must be a number field") #The Complex case is hard to implement and needs to be done later if sqrt(self.degree()) != int(sqrt(self.degree())): raise NotImplementedError("Map is not Lattes or is Complex Lattes") - from sage.rings.qqbar import QQbar, number_field_elements_from_algebraics - from sage.schemes.elliptic_curves.constructor import EllipticCurve - d = self.degree() + if check_lattes: + V = self.is_Lattes() + if not V: + raise ValueError("Map is not Lattes") n = int(sqrt(self.degree())) #Creating a Symbolic Lattes map f_sym from a short Elliptic curve - R = PolynomialRing(self.base_ring(),6,"a, b, u, v, w, t") + R = PolynomialRing(self.base_ring(), 6, "avar, bvar, uvar, vvar, wvar, tvar") a, b, u, v, w, t = R.gens() + P = ProjectiveSpace(R, 1, self.domain().gens()) E_sym = EllipticCurve([a, b]) - P = ProjectiveSpace(R,1,"x, y") - x, y = P.gens() f_sym = P.Lattes_map(E_sym, n) # Conjugating f_sym map to have the right form so we can solve for the conjugating matrix later m = matrix(R, 2, [u, v, t, w]) @@ -6936,12 +6982,8 @@ def Lattes_to_curve(self, return_conjugation=False): f_sym.scale_by(u*w - v*t) F_sym = f_sym.dehomogenize(1) #extracting the base variables to do term by term matching - P = ProjectiveSpace(self.base_ring(), 1, "x, y") - x, y = P.gens() self.scale_by(1/self[0].lc()) F = self.dehomogenize(1) - x = F[0].parent().gen(0) - z = F_sym[0].parent().gen(0) #Creating a set of equations, eq, from term by term matching eq = [u*w - v*t-1] for j in range(2): @@ -6951,25 +6993,27 @@ def Lattes_to_curve(self, return_conjugation=False): else: g = F[0].denominator() g_sym = F_sym[0].denominator() - for i in range(d + 1): - eq += [g.coefficient({x:i}) - g_sym.coefficient({z:i})] + eq += (g - g_sym).coefficients() #Solving the equations - I = R.ideal(eq) - pts = I.variety(ring=QQbar) - a = pts[0]['a'] - b = pts[0]['b'] - u = pts[0]['u'] - v = pts[0]['v'] - t = pts[0]['t'] - w = pts[0]['w'] + phi = QQbar.coerce_map_from(R.base_ring()) + if phi is None: + phi = R.base_ring().embeddings(QQbar)[0] + eq = [poly.numerator().change_ring(phi) for poly in eq] + I = eq[0].parent().ideal(eq) + pts = I.variety() + a = pts[0]['avar'] + b = pts[0]['bvar'] + u = pts[0]['uvar'] + v = pts[0]['vvar'] + t = pts[0]['tvar'] + w = pts[0]['wvar'] K, [a, b, u, v, t, w], phi = number_field_elements_from_algebraics([a, b, u, v, t, w]) #creating our end products E = EllipticCurve([a, b]) if return_conjugation: M = matrix(K, 2, 2, [u, v, t, w]) return (M, E) - else: - return E + return E class DynamicalSystem_projective_field(DynamicalSystem_projective, SchemeMorphism_polynomial_projective_space_field): From 11f39c6271f45f9057b5b098ed9328c153968310 Mon Sep 17 00:00:00 2001 From: vboxuser Date: Tue, 16 Jul 2024 13:16:11 -0500 Subject: [PATCH 24/91] Lint --- src/sage/dynamics/arithmetic_dynamics/projective_ds.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index c12bde6ec6f..fa17137fdf3 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6887,7 +6887,7 @@ def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): ( [ 1 19/24*a + 19/24] [ 0 1], - Elliptic Curve defined by y^2 = x^3 + 95/96*a*x + (-1169/3456*a+1169/3456) + Elliptic Curve defined by y^2 = x^3 + 95/96*a*x + (-1169/3456*a+1169/3456) over Number Field in a with defining polynomial y^2 + 1 ) @@ -6902,7 +6902,7 @@ def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): ( [11/1602*a^2 41/3204*a^2] [ -2/5*a -1/5*a], - Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) + Elliptic Curve defined by y^2 = x^3 + 2375/3421872*a^2*x + (-254125/61593696) over Number Field in a with defining polynomial y^3 - 267 ) @@ -6955,7 +6955,7 @@ def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): sage: E=EllipticCurve([1,x]) sage: f=P.Lattes_map(E,2) sage: f.Lattes_to_curve() - Elliptic Curve defined by y^2 = x^3 + x + a + Elliptic Curve defined by y^2 = x^3 + x + a over Number Field in a with defining polynomial y^2 - 2 """ From 5cd5040b5ef85fbedfb7587bdc09072ad76ea06b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 27 Jun 2024 16:48:32 -0700 Subject: [PATCH 25/91] Deprecate is_SchemeTopologicalPoint --- src/sage/schemes/generic/point.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/schemes/generic/point.py b/src/sage/schemes/generic/point.py index 7ef85645f56..3bf3480c8bf 100644 --- a/src/sage/schemes/generic/point.py +++ b/src/sage/schemes/generic/point.py @@ -73,6 +73,10 @@ def _repr_(self): ######################################################## def is_SchemeTopologicalPoint(x): + from sage.misc.superseded import deprecation + deprecation(38296, + "The function is_SchemeTopologicalPoint is deprecated; " + "use 'isinstance(..., SchemeTopologicalPoint)' instead.") return isinstance(x, SchemeTopologicalPoint) class SchemeTopologicalPoint(SchemePoint): From 88c4e5d8160d50d54555be95d49536ab26eee9ca Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 27 Jun 2024 17:21:17 -0700 Subject: [PATCH 26/91] Deprecate is_SchemeMorphism --- src/sage/schemes/generic/morphism.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 8034d0b9b5a..3fe58df04de 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -74,20 +74,23 @@ # https://www.gnu.org/licenses/ # **************************************************************************** - import operator -from sage.structure.element import Element, parent, coercion_model + from sage.arith.power import generic_power -from sage.structure.richcmp import richcmp -from sage.structure.sequence import Sequence from sage.categories.homset import Homset, Hom, End -from sage.rings.fraction_field_element import FractionFieldElement -from sage.rings.fraction_field import FractionField_generic from sage.categories.map import FormalCompositeMap, Map +from sage.categories.morphism import SetMorphism from sage.misc.constant_function import ConstantFunction from sage.misc.lazy_attribute import lazy_attribute -from sage.categories.morphism import SetMorphism +from sage.misc.lazy_import import lazy_import +from sage.rings.fraction_field import FractionField_generic +from sage.rings.fraction_field_element import FractionFieldElement from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme +from sage.structure.element import Element, parent, coercion_model +from sage.structure.richcmp import richcmp +from sage.structure.sequence import Sequence + +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') def is_SchemeMorphism(f): @@ -111,9 +114,16 @@ def is_SchemeMorphism(f): Defn: Defined on coordinates by sending (x, y) to (y, x^2 + y) sage: from sage.schemes.generic.morphism import is_SchemeMorphism sage: is_SchemeMorphism(f) + doctest:warning... + DeprecationWarning: The function is_SchemeMorphism is deprecated; + use 'isinstance(..., (SchemeMorphism, EllipticCurvePoint_field))' instead. + See https://github.com/sagemath/sage/issues/38296 for details. True """ - from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field + from sage.misc.superseded import deprecation + deprecation(38296, + "The function is_SchemeMorphism is deprecated; " + "use 'isinstance(..., (SchemeMorphism, EllipticCurvePoint_field))' instead.") return isinstance(f, (SchemeMorphism, EllipticCurvePoint_field)) From ff20ad6cb4ccd9b98841182f3cfd34895f2c561c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 27 Jun 2024 18:06:10 -0700 Subject: [PATCH 27/91] Replace uses of is_SchemeMorphism --- src/sage/categories/schemes.py | 13 +++++++------ src/sage/schemes/affine/affine_point.py | 8 ++++++-- src/sage/schemes/elliptic_curves/ell_point.py | 10 +++++++--- src/sage/schemes/generic/divisor.py | 10 ++++++---- src/sage/schemes/generic/glue.py | 14 +++++++++----- src/sage/schemes/generic/scheme.py | 15 +++++++++------ .../hyperelliptic_curves/jacobian_homset.py | 17 ++++++++++------- src/sage/schemes/projective/projective_point.py | 8 ++++---- src/sage/schemes/toric/morphism.py | 8 ++++---- 9 files changed, 62 insertions(+), 41 deletions(-) diff --git a/src/sage/categories/schemes.py b/src/sage/categories/schemes.py index d0b99f271eb..8ee338244df 100644 --- a/src/sage/categories/schemes.py +++ b/src/sage/categories/schemes.py @@ -24,6 +24,12 @@ from sage.categories.fields import Fields from sage.categories.homsets import HomsetsCategory from sage.misc.abstract_method import abstract_method +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.categories.map', 'Map') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.generic.scheme', 'Scheme') class Schemes(Category): @@ -140,15 +146,10 @@ def _call_(self, x): To: Rational Field """ - from sage.schemes.generic.scheme import Scheme - if isinstance(x, Scheme): - return x - from sage.schemes.generic.morphism import is_SchemeMorphism - if is_SchemeMorphism(x): + if isinstance(x, (EllipticCurvePoint_field, SchemeMorphism, Scheme)): return x from sage.categories.commutative_rings import CommutativeRings from sage.schemes.generic.spec import Spec - from sage.categories.map import Map if x in CommutativeRings(): return Spec(x) elif isinstance(x, Map) and x.category_for().is_subcategory(Rings()): diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index bf6dc2258bc..2e1d4821bc5 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -22,10 +22,14 @@ # **************************************************************************** from sage.categories.number_fields import NumberFields +from sage.misc.lazy_import import lazy_import from sage.rings.integer_ring import ZZ -from sage.schemes.generic.morphism import SchemeMorphism_point, SchemeMorphism, is_SchemeMorphism +from sage.schemes.generic.morphism import SchemeMorphism_point, SchemeMorphism from sage.structure.sequence import Sequence +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') + _NumberFields = NumberFields() @@ -69,7 +73,7 @@ def __init__(self, X, v, check=True): SchemeMorphism.__init__(self, X) if check: from sage.categories.commutative_rings import CommutativeRings - if is_SchemeMorphism(v): + if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): v = list(v) else: try: diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 63d50cc0b0d..6262cde5c06 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -117,6 +117,7 @@ import math +from sage.misc.lazy_import import lazy_import from sage.rings.padics.factory import Qp from sage.rings.padics.precision_error import PrecisionError @@ -140,10 +141,12 @@ from sage.schemes.curves.projective_curve import Hasse_bounds from sage.schemes.projective.projective_point import (SchemeMorphism_point_projective_ring, SchemeMorphism_point_abelian_variety_field) -from sage.schemes.generic.morphism import is_SchemeMorphism from .constructor import EllipticCurve +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') + try: from sage.libs.pari.all import pari, PariError from cypari2.pari_instance import prec_words_to_bits @@ -179,7 +182,8 @@ def curve(self): sage: K. = NumberField(x^2 - 3,'a') # needs sage.rings.number_field sage: P = E.base_extend(K)(1, a) # needs sage.rings.number_field sage: P.scheme() # needs sage.rings.number_field - Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3 + Elliptic Curve defined by y^2 = x^3 + x + 1 over + Number Field in a with defining polynomial x^2 - 3 """ return self.scheme() @@ -294,7 +298,7 @@ def __init__(self, curve, v, check=True): """ point_homset = curve.point_homset() R = point_homset.value_ring() - if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): + if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)) v = list(v) elif v == 0: v = (R.zero(), R.one(), R.zero()) diff --git a/src/sage/schemes/generic/divisor.py b/src/sage/schemes/generic/divisor.py index d46b8caff0e..8e72d2d816a 100644 --- a/src/sage/schemes/generic/divisor.py +++ b/src/sage/schemes/generic/divisor.py @@ -42,14 +42,16 @@ #******************************************************************************* from sage.misc.latex import latex +from sage.misc.lazy_import import lazy_import from sage.misc.repr import repr_lincomb from sage.misc.search import search from sage.rings.integer_ring import ZZ -from sage.structure.formal_sum import FormalSum - -from .morphism import is_SchemeMorphism from sage.schemes.affine.affine_space import AffineSpace_generic from sage.schemes.projective.projective_space import ProjectiveSpace_ring +from sage.structure.formal_sum import FormalSum + +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') def CurvePointToIdeal(C,P): @@ -358,7 +360,7 @@ def __init__(self, v, parent=None, check=True, reduce=True): else: n = ZZ(1) I = t - if is_SchemeMorphism(I): + if isinstance(I, (SchemeMorphism, EllipticCurvePoint_field)): I = CurvePointToIdeal(C,I) else: know_points = False diff --git a/src/sage/schemes/generic/glue.py b/src/sage/schemes/generic/glue.py index e70aafa0507..9c2bc938f33 100644 --- a/src/sage/schemes/generic/glue.py +++ b/src/sage/schemes/generic/glue.py @@ -8,10 +8,14 @@ # http://www.gnu.org/licenses/ #******************************************************************************* -from . import morphism -from . import scheme +from sage.misc.lazy_import import lazy_import +from sage.schemes.generic.scheme import Scheme -class GluedScheme(scheme.Scheme): +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') + + +class GluedScheme(Scheme): r""" INPUT: @@ -48,9 +52,9 @@ class GluedScheme(scheme.Scheme): """ def __init__(self, f, g, check=True): if check: - if not morphism.is_SchemeMorphism(f): + if not isinstance(f, (SchemeMorphism, EllipticCurvePoint_field)): raise TypeError("f (=%s) must be a scheme morphism" % f) - if not morphism.is_SchemeMorphism(g): + if not isinstance(g, (SchemeMorphism, EllipticCurvePoint_field)): raise TypeError("g (=%s) must be a scheme morphism" % g) if f.domain() != g.domain(): raise ValueError("f (=%s) and g (=%s) must have the same domain" % (f,g)) diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py index 715c9d2a687..28a3cdd3d11 100644 --- a/src/sage/schemes/generic/scheme.py +++ b/src/sage/schemes/generic/scheme.py @@ -19,13 +19,17 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.structure.parent import Parent -from sage.misc.cachefunc import cached_method -from sage.rings.integer_ring import ZZ from sage.categories.commutative_rings import CommutativeRings +from sage.misc.cachefunc import cached_method +from sage.misc.lazy_import import lazy_import from sage.rings.ideal import is_Ideal -from sage.structure.unique_representation import UniqueRepresentation +from sage.rings.integer_ring import ZZ from sage.schemes.generic.point import SchemeTopologicalPoint_prime_ideal +from sage.structure.parent import Parent +from sage.structure.unique_representation import UniqueRepresentation + +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') def is_Scheme(x): @@ -104,7 +108,6 @@ def __init__(self, X=None, category=None): sage: TestSuite(X).run() # needs sage.libs.singular """ - from sage.schemes.generic.morphism import is_SchemeMorphism from sage.categories.map import Map from sage.categories.rings import Rings @@ -112,7 +115,7 @@ def __init__(self, X=None, category=None): self._base_ring = ZZ elif isinstance(X, Scheme): self._base_scheme = X - elif is_SchemeMorphism(X): + elif isinstance(X, (SchemeMorphism, EllipticCurvePoint_field)): self._base_morphism = X elif X in CommutativeRings(): self._base_ring = X diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py index 2a192248180..41ef57b8e72 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py @@ -42,14 +42,16 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.integer_ring import ZZ +from sage.misc.lazy_import import lazy_import from sage.rings.integer import Integer +from sage.rings.integer_ring import ZZ from sage.rings.polynomial.polynomial_element import Polynomial - +from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.schemes.generic.homset import SchemeHomset_points -from sage.schemes.generic.morphism import is_SchemeMorphism -from .jacobian_morphism import JacobianMorphism_divisor_class_field +from sage.schemes.hyperelliptic_curves.jacobian_morphism import JacobianMorphism_divisor_class_field + +lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') class JacobianHomset_divisor_classes(SchemeHomset_points): @@ -139,12 +141,13 @@ def __call__(self, P): return JacobianMorphism_divisor_class_field(self, (P1, P2)) if isinstance(P1, Polynomial) and isinstance(P2, Polynomial): return JacobianMorphism_divisor_class_field(self, tuple(P)) - if is_SchemeMorphism(P1) and is_SchemeMorphism(P2): + if (isinstance(P1, (SchemeMorphism, EllipticCurvePoint_field)) + and isinstance(P2, (SchemeMorphism, EllipticCurvePoint_field))): return self(P1) - self(P2) raise TypeError("argument P (= %s) must have length 2" % P) elif isinstance(P, JacobianMorphism_divisor_class_field) and self == P.parent(): return P - elif is_SchemeMorphism(P): + elif isinstance(P, (SchemeMorphism, EllipticCurvePoint_field)): x0 = P[0] y0 = P[1] R, x = PolynomialRing(self.value_ring(), 'x').objgen() diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 1efc16af934..91d7aa49a63 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -38,15 +38,16 @@ from sage.arith.misc import GCD as gcd from sage.arith.functions import lcm from sage.misc.misc_c import prod +from sage.misc.lazy_import import lazy_import from copy import copy from sage.schemes.generic.morphism import (SchemeMorphism, - is_SchemeMorphism, SchemeMorphism_point) from sage.structure.element import AdditiveGroupElement from sage.structure.sequence import Sequence from sage.structure.richcmp import richcmp, op_EQ, op_NE +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') # -------------------- # Projective varieties @@ -164,7 +165,7 @@ def __init__(self, X, v, check=True): from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field from sage.rings.ring import CommutativeRing d = X.codomain().ambient_space().ngens() - if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): + if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): v = list(v) else: try: @@ -1138,10 +1139,9 @@ def __init__(self, X, v, check=True): self._normalized = False if check: - from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field from sage.rings.ring import CommutativeRing d = X.codomain().ambient_space().ngens() - if is_SchemeMorphism(v) or isinstance(v, EllipticCurvePoint_field): + if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): v = list(v) else: try: diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py index e95e071d864..f53287847c0 100644 --- a/src/sage/schemes/toric/morphism.py +++ b/src/sage/schemes/toric/morphism.py @@ -362,24 +362,24 @@ # the toric varieties level from Morphism. See # https://groups.google.com/d/msg/sage-devel/qF4yU6Vdmao/wQlNrneSmWAJ from sage.categories.morphism import Morphism - from sage.structure.richcmp import richcmp_not_equal, richcmp - from sage.structure.sequence import Sequence from sage.rings.integer_ring import ZZ from sage.arith.misc import GCD as gcd from sage.misc.cachefunc import cached_method from sage.matrix.constructor import matrix, identity_matrix +from sage.misc.lazy_import import lazy_import from sage.modules.free_module_element import vector from sage.geometry.cone import Cone from sage.geometry.fan import Fan from sage.schemes.generic.scheme import Scheme from sage.schemes.generic.morphism import ( - is_SchemeMorphism, SchemeMorphism, SchemeMorphism_point, SchemeMorphism_polynomial ) +lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') + ############################################################################ # A points on a toric variety determined by homogeneous coordinates. @@ -431,7 +431,7 @@ def __init__(self, X, coordinates, check=True): if check: # Verify that there are the right number of coords # Why is it not done in the parent? - if is_SchemeMorphism(coordinates): + if isinstance(coordinates, (SchemeMorphism, EllipticCurvePoint_field)): coordinates = list(coordinates) if not isinstance(coordinates, (list, tuple)): raise TypeError("coordinates must be a scheme point, list, " From 92a768ae57426a5e9aa34c0de6a7366809ceca2e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 27 Jun 2024 18:25:56 -0700 Subject: [PATCH 28/91] Fixup --- src/sage/schemes/affine/affine_point.py | 1 - src/sage/schemes/elliptic_curves/ell_point.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index 2e1d4821bc5..4aedd5e5f26 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -27,7 +27,6 @@ from sage.schemes.generic.morphism import SchemeMorphism_point, SchemeMorphism from sage.structure.sequence import Sequence -lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') _NumberFields = NumberFields() diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 6262cde5c06..53cbad7f266 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -298,7 +298,7 @@ def __init__(self, curve, v, check=True): """ point_homset = curve.point_homset() R = point_homset.value_ring() - if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)) + if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): v = list(v) elif v == 0: v = (R.zero(), R.one(), R.zero()) From 2cd04766920fedcab096d97fdc4236c0da583d20 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 17 Jul 2024 19:04:00 +0900 Subject: [PATCH 29/91] Simplify isinstance calls based on issubclass(EllipticCurvePoint_field, SchemeMorphism) -> True --- src/sage/categories/schemes.py | 3 +-- src/sage/schemes/affine/affine_point.py | 4 +--- src/sage/schemes/elliptic_curves/ell_point.py | 3 +-- src/sage/schemes/generic/divisor.py | 3 +-- src/sage/schemes/generic/glue.py | 5 ++--- src/sage/schemes/generic/morphism.py | 8 +++----- src/sage/schemes/generic/scheme.py | 3 +-- src/sage/schemes/hyperelliptic_curves/jacobian_homset.py | 6 ++---- src/sage/schemes/projective/projective_point.py | 7 ++----- src/sage/schemes/toric/morphism.py | 4 +--- 10 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/sage/categories/schemes.py b/src/sage/categories/schemes.py index 8ee338244df..f00346ec59f 100644 --- a/src/sage/categories/schemes.py +++ b/src/sage/categories/schemes.py @@ -27,7 +27,6 @@ from sage.misc.lazy_import import lazy_import lazy_import('sage.categories.map', 'Map') -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') lazy_import('sage.schemes.generic.scheme', 'Scheme') @@ -146,7 +145,7 @@ def _call_(self, x): To: Rational Field """ - if isinstance(x, (EllipticCurvePoint_field, SchemeMorphism, Scheme)): + if isinstance(x, (SchemeMorphism, Scheme)): return x from sage.categories.commutative_rings import CommutativeRings from sage.schemes.generic.spec import Spec diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index 4aedd5e5f26..206fd0b00f0 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -27,8 +27,6 @@ from sage.schemes.generic.morphism import SchemeMorphism_point, SchemeMorphism from sage.structure.sequence import Sequence -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') - _NumberFields = NumberFields() @@ -72,7 +70,7 @@ def __init__(self, X, v, check=True): SchemeMorphism.__init__(self, X) if check: from sage.categories.commutative_rings import CommutativeRings - if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): + if isinstance(v, SchemeMorphism): v = list(v) else: try: diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 53cbad7f266..196312f5720 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -145,7 +145,6 @@ from .constructor import EllipticCurve lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') try: from sage.libs.pari.all import pari, PariError @@ -298,7 +297,7 @@ def __init__(self, curve, v, check=True): """ point_homset = curve.point_homset() R = point_homset.value_ring() - if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): + if isinstance(v, SchemeMorphism): v = list(v) elif v == 0: v = (R.zero(), R.one(), R.zero()) diff --git a/src/sage/schemes/generic/divisor.py b/src/sage/schemes/generic/divisor.py index 8e72d2d816a..27d8dbfa45c 100644 --- a/src/sage/schemes/generic/divisor.py +++ b/src/sage/schemes/generic/divisor.py @@ -51,7 +51,6 @@ from sage.structure.formal_sum import FormalSum lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') def CurvePointToIdeal(C,P): @@ -360,7 +359,7 @@ def __init__(self, v, parent=None, check=True, reduce=True): else: n = ZZ(1) I = t - if isinstance(I, (SchemeMorphism, EllipticCurvePoint_field)): + if isinstance(I, SchemeMorphism): I = CurvePointToIdeal(C,I) else: know_points = False diff --git a/src/sage/schemes/generic/glue.py b/src/sage/schemes/generic/glue.py index 9c2bc938f33..1e4256e4b3d 100644 --- a/src/sage/schemes/generic/glue.py +++ b/src/sage/schemes/generic/glue.py @@ -12,7 +12,6 @@ from sage.schemes.generic.scheme import Scheme lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') class GluedScheme(Scheme): @@ -52,9 +51,9 @@ class GluedScheme(Scheme): """ def __init__(self, f, g, check=True): if check: - if not isinstance(f, (SchemeMorphism, EllipticCurvePoint_field)): + if not isinstance(f, SchemeMorphism): raise TypeError("f (=%s) must be a scheme morphism" % f) - if not isinstance(g, (SchemeMorphism, EllipticCurvePoint_field)): + if not isinstance(g, SchemeMorphism): raise TypeError("g (=%s) must be a scheme morphism" % g) if f.domain() != g.domain(): raise ValueError("f (=%s) and g (=%s) must have the same domain" % (f,g)) diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 3fe58df04de..d03be19122c 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -90,8 +90,6 @@ from sage.structure.richcmp import richcmp from sage.structure.sequence import Sequence -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') - def is_SchemeMorphism(f): """ @@ -116,15 +114,15 @@ def is_SchemeMorphism(f): sage: is_SchemeMorphism(f) doctest:warning... DeprecationWarning: The function is_SchemeMorphism is deprecated; - use 'isinstance(..., (SchemeMorphism, EllipticCurvePoint_field))' instead. + use 'isinstance(..., SchemeMorphism)' instead. See https://github.com/sagemath/sage/issues/38296 for details. True """ from sage.misc.superseded import deprecation deprecation(38296, "The function is_SchemeMorphism is deprecated; " - "use 'isinstance(..., (SchemeMorphism, EllipticCurvePoint_field))' instead.") - return isinstance(f, (SchemeMorphism, EllipticCurvePoint_field)) + "use 'isinstance(..., SchemeMorphism)' instead.") + return isinstance(f, SchemeMorphism) class SchemeMorphism(Element): diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py index 28a3cdd3d11..cac07a1e9c7 100644 --- a/src/sage/schemes/generic/scheme.py +++ b/src/sage/schemes/generic/scheme.py @@ -29,7 +29,6 @@ from sage.structure.unique_representation import UniqueRepresentation lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') def is_Scheme(x): @@ -115,7 +114,7 @@ def __init__(self, X=None, category=None): self._base_ring = ZZ elif isinstance(X, Scheme): self._base_scheme = X - elif isinstance(X, (SchemeMorphism, EllipticCurvePoint_field)): + elif isinstance(X, SchemeMorphism): self._base_morphism = X elif X in CommutativeRings(): self._base_ring = X diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py index 41ef57b8e72..29c98369259 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py @@ -51,7 +51,6 @@ from sage.schemes.hyperelliptic_curves.jacobian_morphism import JacobianMorphism_divisor_class_field lazy_import('sage.schemes.generic.morphism', 'SchemeMorphism') -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') class JacobianHomset_divisor_classes(SchemeHomset_points): @@ -141,13 +140,12 @@ def __call__(self, P): return JacobianMorphism_divisor_class_field(self, (P1, P2)) if isinstance(P1, Polynomial) and isinstance(P2, Polynomial): return JacobianMorphism_divisor_class_field(self, tuple(P)) - if (isinstance(P1, (SchemeMorphism, EllipticCurvePoint_field)) - and isinstance(P2, (SchemeMorphism, EllipticCurvePoint_field))): + if isinstance(P1, SchemeMorphism) and isinstance(P2, SchemeMorphism): return self(P1) - self(P2) raise TypeError("argument P (= %s) must have length 2" % P) elif isinstance(P, JacobianMorphism_divisor_class_field) and self == P.parent(): return P - elif isinstance(P, (SchemeMorphism, EllipticCurvePoint_field)): + elif isinstance(P, SchemeMorphism): x0 = P[0] y0 = P[1] R, x = PolynomialRing(self.value_ring(), 'x').objgen() diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 91d7aa49a63..84409b25bef 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -47,8 +47,6 @@ from sage.structure.sequence import Sequence from sage.structure.richcmp import richcmp, op_EQ, op_NE -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') - # -------------------- # Projective varieties # -------------------- @@ -162,10 +160,9 @@ def __init__(self, X, v, check=True): SchemeMorphism.__init__(self, X) if check: - from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field from sage.rings.ring import CommutativeRing d = X.codomain().ambient_space().ngens() - if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): + if isinstance(v, SchemeMorphism): v = list(v) else: try: @@ -1141,7 +1138,7 @@ def __init__(self, X, v, check=True): if check: from sage.rings.ring import CommutativeRing d = X.codomain().ambient_space().ngens() - if isinstance(v, (SchemeMorphism, EllipticCurvePoint_field)): + if isinstance(v, SchemeMorphism): v = list(v) else: try: diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py index f53287847c0..b1097570910 100644 --- a/src/sage/schemes/toric/morphism.py +++ b/src/sage/schemes/toric/morphism.py @@ -378,8 +378,6 @@ SchemeMorphism, SchemeMorphism_point, SchemeMorphism_polynomial ) -lazy_import('sage.schemes.elliptic_curves.ell_point', 'EllipticCurvePoint_field') - ############################################################################ # A points on a toric variety determined by homogeneous coordinates. @@ -431,7 +429,7 @@ def __init__(self, X, coordinates, check=True): if check: # Verify that there are the right number of coords # Why is it not done in the parent? - if isinstance(coordinates, (SchemeMorphism, EllipticCurvePoint_field)): + if isinstance(coordinates, SchemeMorphism): coordinates = list(coordinates) if not isinstance(coordinates, (list, tuple)): raise TypeError("coordinates must be a scheme point, list, " From 95f4c8bebe94a15cd001b96fa3d6bad8de836c82 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 17 Jul 2024 19:08:22 +0900 Subject: [PATCH 30/91] Remove unused imports --- src/sage/schemes/generic/morphism.py | 1 - src/sage/schemes/projective/projective_point.py | 1 - src/sage/schemes/toric/morphism.py | 1 - 3 files changed, 3 deletions(-) diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index d03be19122c..a65d896b96c 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -82,7 +82,6 @@ from sage.categories.morphism import SetMorphism from sage.misc.constant_function import ConstantFunction from sage.misc.lazy_attribute import lazy_attribute -from sage.misc.lazy_import import lazy_import from sage.rings.fraction_field import FractionField_generic from sage.rings.fraction_field_element import FractionFieldElement from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 84409b25bef..fb5265ee3c0 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -38,7 +38,6 @@ from sage.arith.misc import GCD as gcd from sage.arith.functions import lcm from sage.misc.misc_c import prod -from sage.misc.lazy_import import lazy_import from copy import copy from sage.schemes.generic.morphism import (SchemeMorphism, diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py index b1097570910..615de11ebe2 100644 --- a/src/sage/schemes/toric/morphism.py +++ b/src/sage/schemes/toric/morphism.py @@ -368,7 +368,6 @@ from sage.arith.misc import GCD as gcd from sage.misc.cachefunc import cached_method from sage.matrix.constructor import matrix, identity_matrix -from sage.misc.lazy_import import lazy_import from sage.modules.free_module_element import vector from sage.geometry.cone import Cone from sage.geometry.fan import Fan From 3ec03bfebf331167b836368352336224143ed799 Mon Sep 17 00:00:00 2001 From: Aaron Dwyer <109538917+aadwyer@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:59:05 -0400 Subject: [PATCH 31/91] Update covering_array.py Changed ValueError to NotImplementedError --- src/sage/combinat/designs/covering_array.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index dd929ea7845..f956f9808f9 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -161,7 +161,7 @@ def column_Kleitman_Spencer_Katona(k): sage: column_Kleitman_Spencer_Katona(25000) Traceback (most recent call last): ... - ValueError: not implemented for k > 24310 + NotImplementedError: not implemented for k > 24310 """ kdict = [(3, 4), (4, 5), (10, 6), (15, 7), (35, 8), (56, 9), @@ -169,7 +169,7 @@ def column_Kleitman_Spencer_Katona(k): (3003, 15), (6435, 16), (11440, 17), (24310, 18)] if k > kdict[-1][0]: - raise ValueError("not implemented for k > {}".format(kdict[-1][0])) + raise NotImplementedError("not implemented for k > {}".format(kdict[-1][0])) for (ki, N) in kdict: if k <= ki: From f08c3f1e4d0fa5f1779363490dcc81795536f1ce Mon Sep 17 00:00:00 2001 From: Aaron Dwyer <109538917+aadwyer@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:59:21 -0400 Subject: [PATCH 32/91] Update src/sage/combinat/designs/database.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Köppe --- src/sage/combinat/designs/database.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/combinat/designs/database.py b/src/sage/combinat/designs/database.py index f7fc59041f8..919ffb6f24c 100644 --- a/src/sage/combinat/designs/database.py +++ b/src/sage/combinat/designs/database.py @@ -5480,10 +5480,10 @@ def ca_41_2_6_6(): # smallest N and largest k such that a CA(N; t, k, v) can be made using # the database. CA_constructions = { - (2,3) : ((11,5), (12,7), (13,9), (14,10), (15,20)), - (2,4) : ((19,6), (21,7)), - (2,5) : ((29,7),), - (2,6) : ((37,4), (39,5), (41,6)) + (2,3): ((11,5), (12,7), (13,9), (14,10), (15,20)), + (2,4): ((19,6), (21,7)), + (2,5): ((29,7),), + (2,6): ((37,4), (39,5), (41,6)) } # Add this data to the module's doc. From eb5c535caee91f8c4cd9f13b592eb2c6d7b0b14a Mon Sep 17 00:00:00 2001 From: vboxuser Date: Fri, 19 Jul 2024 15:43:41 -0500 Subject: [PATCH 33/91] Expanding to allow is_lattes to check QQbar and adding another error case --- .../arithmetic_dynamics/projective_ds.py | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index fa17137fdf3..546c19075ac 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -6748,8 +6748,9 @@ def is_Lattes(self): """ # We need `f` to be defined over a number field for # the function `is_postcrtically_finite` to work - if self.base_ring() not in NumberFields(): - raise NotImplementedError("Base ring must be a number field") + if self.base_ring() is not QQbar: + if self.base_ring() not in NumberFields(): + raise NotImplementedError("Base ring must be a number field") if self.domain().dimension() != 1: return False @@ -6923,26 +6924,35 @@ def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): :: - sage: P. = ProjectiveSpace(QQ,1) - sage: F = DynamicalSystem_projective([x^4,y^4]) + sage: P. = ProjectiveSpace(RR, 1) + sage: F = DynamicalSystem_projective([x^4, y^4]) sage: F.Lattes_to_curve(check_lattes=True) Traceback (most recent call last): ... - ValueError: Map is not Lattes + NotImplementedError: Base ring must be a number field :: - sage: P. = ProjectiveSpace(QQbar,1) - sage: F = DynamicalSystem_projective([x^4,y^4]) + sage: P. = ProjectiveSpace(QQ, 1) + sage: F = DynamicalSystem_projective([x^4, y^4]) sage: F.Lattes_to_curve(check_lattes=True) Traceback (most recent call last): ... - NotImplementedError: Base ring must be a number field + ValueError: Map is not Lattes :: - sage: P. = ProjectiveSpace(QQ,1) - sage: F = DynamicalSystem_projective([x^3,y^3]) + sage: P. = ProjectiveSpace(QQ, 1) + sage: F = DynamicalSystem_projective([x^4, y^4]) + sage: F.Lattes_to_curve() + Traceback (most recent call last): + ... + ValueError: No Solutions found. Check if map is Lattes + + :: + + sage: P. = ProjectiveSpace(QQ, 1) + sage: F = DynamicalSystem_projective([x^3, y^3]) sage: F.Lattes_to_curve(check_lattes=True) Traceback (most recent call last): ... @@ -6951,13 +6961,21 @@ def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): :: sage: K.=QuadraticField(2) - sage: P.=ProjectiveSpace(K,1) - sage: E=EllipticCurve([1,x]) - sage: f=P.Lattes_map(E,2) + sage: P.=ProjectiveSpace(K, 1) + sage: E=EllipticCurve([1, x]) + sage: f=P.Lattes_map(E, 2) sage: f.Lattes_to_curve() Elliptic Curve defined by y^2 = x^3 + x + a over Number Field in a with defining polynomial y^2 - 2 + :: + + sage: P.=ProjectiveSpace(QQbar, 1) + sage: E=EllipticCurve([1, 2]) + sage: f=P.Lattes_map(E, 2) + sage: f.Lattes_to_curve(check_lattes=true) + Elliptic Curve defined by y^2 = x^3 + x + 2 over Rational Field + """ if self.base_ring() is not QQbar: if self.base_ring() not in NumberFields(): @@ -7001,6 +7019,8 @@ def Lattes_to_curve(self, return_conjugation=False, check_lattes=False): eq = [poly.numerator().change_ring(phi) for poly in eq] I = eq[0].parent().ideal(eq) pts = I.variety() + if len(pts) == 0: + raise ValueError("No Solutions found. Check if map is Lattes") a = pts[0]['avar'] b = pts[0]['bvar'] u = pts[0]['uvar'] From 5c0d5ea14e765514f225cd2269ba0c04726ec475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 20 Jul 2024 14:19:45 +0200 Subject: [PATCH 34/91] get rid of some sage-eval in gap3-related code --- src/sage/combinat/root_system/reflection_group_complex.py | 2 +- .../combinat/root_system/reflection_group_element.pyx | 8 +++++--- src/sage/combinat/root_system/reflection_group_real.py | 7 +++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/sage/combinat/root_system/reflection_group_complex.py b/src/sage/combinat/root_system/reflection_group_complex.py index d4c6c5b677b..21f8c2f70a7 100644 --- a/src/sage/combinat/root_system/reflection_group_complex.py +++ b/src/sage/combinat/root_system/reflection_group_complex.py @@ -971,7 +971,7 @@ def conjugacy_classes_representatives(self): """ # This can be converted to usual GAP S = str(gap3('List(ConjugacyClasses(%s),Representative)' % self._gap_group._name)) - return sage_eval(_gap_return(S), {'self': self}) + return [self(w, check=False) for w in _gap_return(S)] def conjugacy_classes(self): r""" diff --git a/src/sage/combinat/root_system/reflection_group_element.pyx b/src/sage/combinat/root_system/reflection_group_element.pyx index 3d81a84ff4b..82ec6a6b113 100644 --- a/src/sage/combinat/root_system/reflection_group_element.pyx +++ b/src/sage/combinat/root_system/reflection_group_element.pyx @@ -21,6 +21,7 @@ AUTHORS: # (at your option) any later version. # https://www.gnu.org/licenses/ # *************************************************************************** +import re from sage.misc.lazy_attribute import lazy_attribute from sage.misc.misc_c import prod @@ -31,6 +32,8 @@ from sage.combinat.root_system.reflection_group_c import reduced_word_c, reduce_ from sage.matrix.constructor import Matrix from sage.matrix.special import identity_matrix +TUPLE = re.compile(r'(?:\([0-9,]*\))+') + cdef class ComplexReflectionGroupElement(PermutationGroupElement): """ @@ -1246,8 +1249,7 @@ def _gap_return(S, coerce_obj='self'): sage: from sage.combinat.root_system.reflection_group_complex import _gap_return sage: _gap_return("[ (), (1,4)(2,3)(5,6), (1,6,2)(3,5,4) ]") # optional - gap3 - "[self('()',check=False),self('(1,4)(2,3)(5,6)',check=False),self('(1,6,2)(3,5,4)',check=False)]" + ['()', '(1,4)(2,3)(5,6)', '(1,6,2)(3,5,4)'] """ S = S.replace(' ', '').replace('\n', '') - S = S.replace(',(', '\',check=False),%s(\'(' % coerce_obj).replace('[', '[%s(\'' % coerce_obj).replace(']', '\',check=False)]') - return S + return TUPLE.findall(S) diff --git a/src/sage/combinat/root_system/reflection_group_real.py b/src/sage/combinat/root_system/reflection_group_real.py index c49c3e8bc6e..c5237a409dc 100644 --- a/src/sage/combinat/root_system/reflection_group_real.py +++ b/src/sage/combinat/root_system/reflection_group_real.py @@ -47,9 +47,9 @@ from sage.misc.cachefunc import cached_function, cached_method, cached_in_parent_method from sage.combinat.root_system.cartan_type import CartanType, CartanType_abstract +from sage.interfaces.gap3 import gap3 from sage.rings.integer_ring import ZZ from sage.combinat.root_system.reflection_group_complex import ComplexReflectionGroup, IrreducibleComplexReflectionGroup -from sage.misc.sage_eval import sage_eval from sage.combinat.root_system.reflection_group_element import RealReflectionGroupElement @@ -695,7 +695,7 @@ def right_coset_representatives(self, J): from sage.combinat.root_system.reflection_group_element import _gap_return J_inv = [self._index_set_inverse[j] + 1 for j in J] S = str(gap3('ReducedRightCosetRepresentatives(%s,ReflectionSubgroup(%s,%s))' % (self._gap_group._name, self._gap_group._name, J_inv))) - return sage_eval(_gap_return(S), locals={'self': self}) + return [self(w) for w in _gap_return(S)] def simple_root_index(self, i): r""" @@ -820,8 +820,7 @@ def right_coset_representatives(self): if self.fix_space().is_subspace(T[i].fix_space())] S = str(gap3('ReducedRightCosetRepresentatives(%s,ReflectionSubgroup(%s,%s))' % (W._gap_group._name, W._gap_group._name, T_fix))) from sage.combinat.root_system.reflection_group_element import _gap_return - return sage_eval(_gap_return(S, coerce_obj='W'), - locals={'self': self, 'W': W}) + return [W(w) for w in _gap_return(S)] def left_coset_representatives(self): r""" From a4aab679dcb8bcecd2a191c0b5c82a4a23157126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 20 Jul 2024 16:11:39 +0200 Subject: [PATCH 35/91] add check=False twice --- src/sage/combinat/root_system/reflection_group_real.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/root_system/reflection_group_real.py b/src/sage/combinat/root_system/reflection_group_real.py index c5237a409dc..8c768f576a7 100644 --- a/src/sage/combinat/root_system/reflection_group_real.py +++ b/src/sage/combinat/root_system/reflection_group_real.py @@ -695,7 +695,7 @@ def right_coset_representatives(self, J): from sage.combinat.root_system.reflection_group_element import _gap_return J_inv = [self._index_set_inverse[j] + 1 for j in J] S = str(gap3('ReducedRightCosetRepresentatives(%s,ReflectionSubgroup(%s,%s))' % (self._gap_group._name, self._gap_group._name, J_inv))) - return [self(w) for w in _gap_return(S)] + return [self(w, check=False) for w in _gap_return(S)] def simple_root_index(self, i): r""" @@ -820,7 +820,7 @@ def right_coset_representatives(self): if self.fix_space().is_subspace(T[i].fix_space())] S = str(gap3('ReducedRightCosetRepresentatives(%s,ReflectionSubgroup(%s,%s))' % (W._gap_group._name, W._gap_group._name, T_fix))) from sage.combinat.root_system.reflection_group_element import _gap_return - return [W(w) for w in _gap_return(S)] + return [W(w, check=False) for w in _gap_return(S)] def left_coset_representatives(self): r""" From 58f76139c2c19082cb05c304442e195ce148aa16 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Mon, 22 Jul 2024 14:21:57 -0700 Subject: [PATCH 36/91] xgcd for multiple arguments + examples --- src/sage/arith/misc.py | 54 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 28f81d7b798..ae41f66a09f 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -1955,7 +1955,7 @@ def xlcm(m, n): return (l, m, n) -def xgcd(a, b): +def xgcd(a, b=None): r""" Return a triple ``(g,s,t)`` such that `g = s\cdot a+t\cdot b = \gcd(a,b)`. @@ -1970,12 +1970,22 @@ def xgcd(a, b): INPUT: + One of the following: + - ``a, b`` -- integers or more generally, element of a ring for which the xgcd make sense (e.g. a field or univariate polynomials). + - ``a`` -- list or tuple of at least two integers or more generally, element + of a ring which the xgcd make sense. + OUTPUT: - - ``g, s, t`` -- such that `g = s\cdot a + t\cdot b` + One of the following: + + - ``g, s, t`` -- when two inputs ``a, b`` are given. They satisfy `g = s\cdot a + t\cdot b`. + + - ``r`` -- when only ``a`` is given (and ``b = None``). The tuple ``r`` has length one longer + than the length of ``a``, and its entries satisfy ``r[0] = \sum_{0 \le i < len(a)} r[i + 1] * a[i]``. .. NOTE:: @@ -1988,6 +1998,12 @@ def xgcd(a, b): (4, 4, -5) sage: 4*56 + (-5)*44 4 + sage: xgcd([56, 44]) + (4, 4, -5) + sage: xgcd([30, 105, 70, 42]) + (1, -3, 13, 91, -182) + sage: (-3)*30 + 13*105 + 91*70 + (-182)*42 + 1 sage: g, a, b = xgcd(5/1, 7/1); g, a, b (1, 3, -2) @@ -1997,6 +2013,10 @@ def xgcd(a, b): sage: x = polygen(QQ) sage: xgcd(x^3 - 1, x^2 - 1) (x - 1, 1, -x) + sage: g, a, b, c = xgcd([x^4 - x, x^6 - 1, x^4 - 1]); g, a, b, c + (x - 1, -1, x^2 + 1, -x^4 - x^2) + sage: a*(x^4 - x) + b*(x^6 - 1) + c*(x^4 - 1) == g + True sage: K. = NumberField(x^2 - 3) # needs sage.rings.number_field sage: g.xgcd(g + 2) # needs sage.rings.number_field @@ -2045,15 +2065,29 @@ def xgcd(a, b): sage: xgcd(y^2, a*h*y + b) (1, 7*a^2/b^2, (((-h)*a)/b^2)*y + 1/b) """ - try: + if b is not None: + # xgcd of two elements + try: + return a.xgcd(b) + except AttributeError: + a = py_scalar_to_element(a) + b = py_scalar_to_element(b) + except TypeError: + b = py_scalar_to_element(b) return a.xgcd(b) - except AttributeError: - a = py_scalar_to_element(a) - b = py_scalar_to_element(b) - except TypeError: - b = py_scalar_to_element(b) - return a.xgcd(b) - + else: + # xgcd of >=2 elements + if not isinstance(a, (tuple, list)): + raise TypeError("Input `a` has to be a tuple or a list.") + if len(a) < 2: + raise ValueError("At least two integers or elements should be given.") + if len(a) == 2: + return xgcd(a[0], a[1]) + else: # Compute xgcd recursively + xgcd_t = xgcd(a[1:]) # xgcd_t[0] = sum(xgcd_t[i] * a[i], 1 \le i \le n-1) + g, c_h, c_t = xgcd(a[0], xgcd_t[0]) # g = c_h * a[0] * c_t * xgcd_t[0] + res = [g, c_h] + [c_t * c for c in xgcd_t[1:]] + return tuple(res) XGCD = xgcd From a678087e9432410911e4d6a208f91554255e66e8 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 09:55:57 -0700 Subject: [PATCH 37/91] lint --- src/sage/arith/misc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index ae41f66a09f..89dc25abf75 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2091,6 +2091,7 @@ def xgcd(a, b=None): XGCD = xgcd + # def XGCD_python(a, b): # """ # Return triple (g,p,q) such that g = p*a+b*q = GCD(a,b). From 3431a23e5c2babdca5c7972fdae11dadd44d4f7d Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 10:08:54 -0700 Subject: [PATCH 38/91] lint --- src/sage/arith/misc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 89dc25abf75..e8863038616 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2089,6 +2089,7 @@ def xgcd(a, b=None): res = [g, c_h] + [c_t * c for c in xgcd_t[1:]] return tuple(res) + XGCD = xgcd From b2a4ec601774997c517c8cc504e393772e54c846 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 10:23:51 -0700 Subject: [PATCH 39/91] more tests for numpy & gmpy2 --- src/sage/arith/misc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index e8863038616..d70b934880f 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2048,11 +2048,15 @@ def xgcd(a, b=None): (4, 1, 0) sage: xgcd(int8(4), int8(8)) # needs numpy (4, 1, 0) + sage: xgcd([int8(4), int8(8), int(10)]) # needs numpy + (2, 0, -1, 1) sage: from gmpy2 import mpz sage: xgcd(mpz(4), mpz(8)) (4, 1, 0) sage: xgcd(4, mpz(8)) (4, 1, 0) + sage: xgcd([4, mpz(8), mpz(10)]) + (2, 0, -1, 1) TESTS: From 0330d7980c88747ec4944f995413a72714129dee Mon Sep 17 00:00:00 2001 From: Seewoo Lee <49933279+seewoo5@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:31:19 -0700 Subject: [PATCH 40/91] Apply suggestions from code review Co-authored-by: grhkm21 <83517584+grhkm21@users.noreply.github.com> --- src/sage/arith/misc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index d70b934880f..ad273249bd2 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -1975,7 +1975,7 @@ def xgcd(a, b=None): - ``a, b`` -- integers or more generally, element of a ring for which the xgcd make sense (e.g. a field or univariate polynomials). - - ``a`` -- list or tuple of at least two integers or more generally, element + - ``a`` -- a list or tuple of at least two integers or more generally, elements of a ring which the xgcd make sense. OUTPUT: @@ -1984,8 +1984,8 @@ def xgcd(a, b=None): - ``g, s, t`` -- when two inputs ``a, b`` are given. They satisfy `g = s\cdot a + t\cdot b`. - - ``r`` -- when only ``a`` is given (and ``b = None``). The tuple ``r`` has length one longer - than the length of ``a``, and its entries satisfy ``r[0] = \sum_{0 \le i < len(a)} r[i + 1] * a[i]``. + - ``r`` -- a tuple, when only ``a`` is given (and ``b = None``). It has length one longer + than the length of ``a``, and its entries satisfy `r_0 = \sum_{i = 0}^{len(a) - 1} r_{i + 1}a_i`. .. NOTE:: @@ -2082,9 +2082,9 @@ def xgcd(a, b=None): else: # xgcd of >=2 elements if not isinstance(a, (tuple, list)): - raise TypeError("Input `a` has to be a tuple or a list.") + raise TypeError("input `a` should be a tuple or a list") if len(a) < 2: - raise ValueError("At least two integers or elements should be given.") + raise ValueError("at least two elements should be given") if len(a) == 2: return xgcd(a[0], a[1]) else: # Compute xgcd recursively From 162144f645e4def34aff38df06104a7f6ef0dcb2 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 10:54:16 -0700 Subject: [PATCH 41/91] remove else & iterative implementation --- src/sage/arith/misc.py | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index ad273249bd2..d77aa18142f 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2000,9 +2000,9 @@ def xgcd(a, b=None): 4 sage: xgcd([56, 44]) (4, 4, -5) - sage: xgcd([30, 105, 70, 42]) - (1, -3, 13, 91, -182) - sage: (-3)*30 + 13*105 + 91*70 + (-182)*42 + sage: r = xgcd([30, 105, 70, 42]); r + (1, -255, 85, -17, -2) + sage: (-255)*30 + 85*105 + (-17)*70 + (-2)*42 1 sage: g, a, b = xgcd(5/1, 7/1); g, a, b @@ -2014,7 +2014,7 @@ def xgcd(a, b=None): sage: xgcd(x^3 - 1, x^2 - 1) (x - 1, 1, -x) sage: g, a, b, c = xgcd([x^4 - x, x^6 - 1, x^4 - 1]); g, a, b, c - (x - 1, -1, x^2 + 1, -x^4 - x^2) + (x - 1, x^3, -x, 1) sage: a*(x^4 - x) + b*(x^6 - 1) + c*(x^4 - 1) == g True @@ -2049,14 +2049,14 @@ def xgcd(a, b=None): sage: xgcd(int8(4), int8(8)) # needs numpy (4, 1, 0) sage: xgcd([int8(4), int8(8), int(10)]) # needs numpy - (2, 0, -1, 1) + (2, -2, 0, 1) sage: from gmpy2 import mpz sage: xgcd(mpz(4), mpz(8)) (4, 1, 0) sage: xgcd(4, mpz(8)) (4, 1, 0) sage: xgcd([4, mpz(8), mpz(10)]) - (2, 0, -1, 1) + (2, -2, 0, 1) TESTS: @@ -2079,19 +2079,20 @@ def xgcd(a, b=None): except TypeError: b = py_scalar_to_element(b) return a.xgcd(b) - else: - # xgcd of >=2 elements - if not isinstance(a, (tuple, list)): - raise TypeError("input `a` should be a tuple or a list") - if len(a) < 2: - raise ValueError("at least two elements should be given") - if len(a) == 2: - return xgcd(a[0], a[1]) - else: # Compute xgcd recursively - xgcd_t = xgcd(a[1:]) # xgcd_t[0] = sum(xgcd_t[i] * a[i], 1 \le i \le n-1) - g, c_h, c_t = xgcd(a[0], xgcd_t[0]) # g = c_h * a[0] * c_t * xgcd_t[0] - res = [g, c_h] + [c_t * c for c in xgcd_t[1:]] - return tuple(res) + + # xgcd of >=2 elements + if not isinstance(a, (tuple, list)): + raise TypeError("input `a` should be a tuple or a list") + if len(a) < 2: + raise ValueError("at least two elements should be given") + if len(a) == 2: + return xgcd(a[0], a[1]) + else: # Compute xgcd recursively + res = xgcd(a[0], a[1]) + for i in range(2, len(a)): + g, s, t = xgcd(res[0], a[i]) + res = [g] + [s * c for c in res[1:]] + [t] + return tuple(res) XGCD = xgcd From 3b58b1883f59197022edf97bd86bbaddca1f6301 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 11:02:32 -0700 Subject: [PATCH 42/91] update doc & refactor --- src/sage/arith/misc.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index d77aa18142f..bdfecfb3d28 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -1984,8 +1984,9 @@ def xgcd(a, b=None): - ``g, s, t`` -- when two inputs ``a, b`` are given. They satisfy `g = s\cdot a + t\cdot b`. - - ``r`` -- a tuple, when only ``a`` is given (and ``b = None``). It has length one longer - than the length of ``a``, and its entries satisfy `r_0 = \sum_{i = 0}^{len(a) - 1} r_{i + 1}a_i`. + - ``r`` -- a tuple, when only ``a`` is given (and ``b = None``). Its first entry ``r[0]`` is the gcd of the inputs, + and has length one longer than the length of ``a``. + Its entries satisfy `r_0 = \sum_{i = 0}^{len(a) - 1} r_{i + 1}a_i`. .. NOTE:: @@ -2085,14 +2086,12 @@ def xgcd(a, b=None): raise TypeError("input `a` should be a tuple or a list") if len(a) < 2: raise ValueError("at least two elements should be given") - if len(a) == 2: - return xgcd(a[0], a[1]) - else: # Compute xgcd recursively - res = xgcd(a[0], a[1]) - for i in range(2, len(a)): - g, s, t = xgcd(res[0], a[i]) - res = [g] + [s * c for c in res[1:]] + [t] - return tuple(res) + # Compute xgcd recursively + res = xgcd(a[0], a[1]) + for i in range(2, len(a)): + g, s, t = xgcd(res[0], a[i]) + res = [g] + [s * c for c in res[1:]] + [t] + return tuple(res) XGCD = xgcd From fc9a608405603dbb4ff89ab4ff0f7274d274b9e9 Mon Sep 17 00:00:00 2001 From: Seewoo Lee <49933279+seewoo5@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:20:56 -0700 Subject: [PATCH 43/91] Use `Sequence`, include length zero input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Julian Rüth --- src/sage/arith/misc.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index bdfecfb3d28..6dbf070edac 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2084,12 +2084,12 @@ def xgcd(a, b=None): # xgcd of >=2 elements if not isinstance(a, (tuple, list)): raise TypeError("input `a` should be a tuple or a list") - if len(a) < 2: - raise ValueError("at least two elements should be given") - # Compute xgcd recursively - res = xgcd(a[0], a[1]) - for i in range(2, len(a)): - g, s, t = xgcd(res[0], a[i]) + if len(a) == 0: + return (ZZ(0),) + a = Sequence(a, use_sage_types=True) + res = [a.universe().zero()] + for b in a: + g, s, t = xgcd(res[0], b) res = [g] + [s * c for c in res[1:]] + [t] return tuple(res) From dae62ae67a0be023f7e2fee0feff16c876c1356d Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 13:42:33 -0700 Subject: [PATCH 44/91] add new test cases --- src/sage/arith/misc.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 6dbf070edac..29cbbb5477d 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -23,6 +23,7 @@ from sage.structure.element import parent from sage.structure.coerce import py_scalar_to_element +from sage.structure.sequence import Sequence from sage.rings.integer import Integer, GCD_list from sage.rings.integer_ring import ZZ @@ -1957,11 +1958,14 @@ def xlcm(m, n): def xgcd(a, b=None): r""" - Return a triple ``(g,s,t)`` such that `g = s\cdot a+t\cdot b = \gcd(a,b)`. + When both ``a`` and ``b`` are given, then return a triple ``(g,s,t)`` + such that `g = s\cdot a+t\cdot b = \gcd(a,b)`. + When only ``a`` is given, then return a tuple ``r`` of length ``len(a) + 1`` + such that `r_0 = \sum_{i = 0}^{len(a) - 1} r_{i + 1}a_i = gcd(a_0, \dots, a_{len(a) - 1})` .. NOTE:: - One exception is if `a` and `b` are not in a principal ideal domain (see + One exception is if the elements are not in a principal ideal domain (see :wikipedia:`Principal_ideal_domain`), e.g., they are both polynomials over the integers. Then this function can't in general return ``(g,s,t)`` as above, since they need not exist. Instead, over the integers, we @@ -2005,6 +2009,10 @@ def xgcd(a, b=None): (1, -255, 85, -17, -2) sage: (-255)*30 + 85*105 + (-17)*70 + (-2)*42 1 + sage: xgcd([]) + (0,) + sage: xgcd([42]) + (42, 1) sage: g, a, b = xgcd(5/1, 7/1); g, a, b (1, 3, -2) @@ -2069,6 +2077,19 @@ def xgcd(a, b=None): sage: S. = R.fraction_field()[] sage: xgcd(y^2, a*h*y + b) (1, 7*a^2/b^2, (((-h)*a)/b^2)*y + 1/b) + + Tests with randomly generated integers:: + + sage: import numpy as np + sage: N, M = 1000, 10000 + sage: a = np.random.randint(M, size=N) * np.random.randint(M) + sage: r = xgcd(a) + sage: len(r) == len(a) + 1 + True + sage: r[0] == gcd(a) + True + sage: sum(c * x for c, x in zip(r[1:], a)) == gcd(a) + True """ if b is not None: # xgcd of two elements @@ -2082,8 +2103,6 @@ def xgcd(a, b=None): return a.xgcd(b) # xgcd of >=2 elements - if not isinstance(a, (tuple, list)): - raise TypeError("input `a` should be a tuple or a list") if len(a) == 0: return (ZZ(0),) a = Sequence(a, use_sage_types=True) From 41d8b3febd327f1cfa3ea0c5c13a356a8df0fc47 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 13:44:32 -0700 Subject: [PATCH 45/91] update doc --- src/sage/arith/misc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 29cbbb5477d..faf712ec88a 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -1968,9 +1968,9 @@ def xgcd(a, b=None): One exception is if the elements are not in a principal ideal domain (see :wikipedia:`Principal_ideal_domain`), e.g., they are both polynomials over the integers. Then this function can't in general return ``(g,s,t)`` - as above, since they need not exist. Instead, over the integers, we - first multiply `g` by a divisor of the resultant of `a/g` and `b/g`, up - to sign. + or ``r`` as above, since they need not exist. Instead, over the integers, + when ``a`` and ``b`` are given, we first multiply `g` by a divisor of the + resultant of `a/g` and `b/g`, up to sign. INPUT: From ed3032a8b1da2d1c0c190fd8a01fbf92361c8b25 Mon Sep 17 00:00:00 2001 From: Seewoo Lee Date: Tue, 23 Jul 2024 13:45:44 -0700 Subject: [PATCH 46/91] update comment --- src/sage/arith/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index faf712ec88a..39cbf7d818c 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -2102,7 +2102,7 @@ def xgcd(a, b=None): b = py_scalar_to_element(b) return a.xgcd(b) - # xgcd of >=2 elements + # xgcd for several elements (possibly more than one) if len(a) == 0: return (ZZ(0),) a = Sequence(a, use_sage_types=True) From 96fe28900063d4b6d22e1b369e50ac79aa7e0896 Mon Sep 17 00:00:00 2001 From: Seewoo Lee <49933279+seewoo5@users.noreply.github.com> Date: Wed, 24 Jul 2024 07:15:41 -0700 Subject: [PATCH 47/91] Apply suggestions from code review simplify doc, faster implementation Co-authored-by: grhkm21 <83517584+grhkm21@users.noreply.github.com> --- src/sage/arith/misc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 39cbf7d818c..6b7f5709ea1 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -1958,6 +1958,8 @@ def xlcm(m, n): def xgcd(a, b=None): r""" + Return the greatest common divisor and the Bézout coefficients of the input arguments. + When both ``a`` and ``b`` are given, then return a triple ``(g,s,t)`` such that `g = s\cdot a+t\cdot b = \gcd(a,b)`. When only ``a`` is given, then return a tuple ``r`` of length ``len(a) + 1`` @@ -2109,7 +2111,10 @@ def xgcd(a, b=None): res = [a.universe().zero()] for b in a: g, s, t = xgcd(res[0], b) - res = [g] + [s * c for c in res[1:]] + [t] + res[0] = g + for i in range(1, len(res)): + res[i] *= s + res.append(t) return tuple(res) From 669f0d54e287f0dea8aa33914443efb6631f84de Mon Sep 17 00:00:00 2001 From: dcoudert Date: Sat, 27 Jul 2024 10:50:51 +0200 Subject: [PATCH 48/91] fix memory leak in is_planar --- src/sage/graphs/planarity.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sage/graphs/planarity.pyx b/src/sage/graphs/planarity.pyx index 987669d97fe..e1619626563 100644 --- a/src/sage/graphs/planarity.pyx +++ b/src/sage/graphs/planarity.pyx @@ -135,6 +135,7 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): elif status == NONEMBEDDABLE: # We now know that the graph is nonplanar. if not kuratowski: + gp_Free(&theGraph) return False # With just the current edges, we have a nonplanar graph, # so to isolate a kuratowski subgraph, just keep going. @@ -150,6 +151,7 @@ def is_planar(g, kuratowski=False, set_pos=False, set_embedding=False): if status == NONEMBEDDABLE: # Kuratowski subgraph isolator if not kuratowski: + gp_Free(&theGraph) return False g_dict = {} for i in range(1, theGraph.N + 1): From 49c2c82341610dbe7db1cadd6a8be7a998a84eb5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 27 Jul 2024 17:14:03 -0700 Subject: [PATCH 49/91] build/pkgs/gcc: Update to 13.3.0 --- build/pkgs/gcc/checksums.ini | 4 ++-- build/pkgs/gcc/package-version.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/pkgs/gcc/checksums.ini b/build/pkgs/gcc/checksums.ini index 272d516f07d..f9c9ba9f3a8 100644 --- a/build/pkgs/gcc/checksums.ini +++ b/build/pkgs/gcc/checksums.ini @@ -1,4 +1,4 @@ tarball=gcc-VERSION.tar.xz -sha1=5f95b6d042fb37d45c6cbebfc91decfbc4fb493c -sha256=e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da +sha1=6501872415823c95d48be28853ce3ebd6c1040c4 +sha256=0845e9621c9543a13f484e94584a49ffc0129970e9914624235fc1d061a0c083 upstream_url=https://mirrors.kernel.org/gnu/gcc/gcc-VERSION/gcc-VERSION.tar.xz diff --git a/build/pkgs/gcc/package-version.txt b/build/pkgs/gcc/package-version.txt index 67aee23940e..ac565bc1cab 100644 --- a/build/pkgs/gcc/package-version.txt +++ b/build/pkgs/gcc/package-version.txt @@ -1 +1 @@ -13.2.0 +13.3.0 From 17bf925f4e098bcbf0da308ea8e8cb12c717b6d2 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 27 Jul 2024 17:17:17 -0700 Subject: [PATCH 50/91] build/pkgs/gcc/patches/gcc-13-homebrew.patch: Remove --- build/pkgs/gcc/patches/gcc-13-homebrew.patch | 71 -------------------- 1 file changed, 71 deletions(-) delete mode 100644 build/pkgs/gcc/patches/gcc-13-homebrew.patch diff --git a/build/pkgs/gcc/patches/gcc-13-homebrew.patch b/build/pkgs/gcc/patches/gcc-13-homebrew.patch deleted file mode 100644 index 8cedce8bc46..00000000000 --- a/build/pkgs/gcc/patches/gcc-13-homebrew.patch +++ /dev/null @@ -1,71 +0,0 @@ -Patch included in https://github.com/Homebrew/homebrew-core/blob/50d9d78a4a09b42807b0a8f74f1f2f8933051a7b/Formula/g/gcc@13.rb - -diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x -index 416d2c2e3a4..e52f11d8460 100644 ---- a/fixincludes/fixincl.x -+++ b/fixincludes/fixincl.x -@@ -2,11 +2,11 @@ - * - * DO NOT EDIT THIS FILE (fixincl.x) - * -- * It has been AutoGen-ed January 22, 2023 at 09:03:29 PM by AutoGen 5.18.12 -+ * It has been AutoGen-ed August 17, 2023 at 10:16:38 AM by AutoGen 5.18.12 - * From the definitions inclhack.def - * and the template file fixincl - */ --/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Jan 22 21:03:29 CET 2023 -+/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Aug 17 10:16:38 CEST 2023 - * - * You must regenerate it. Use the ./genfixes script. - * -@@ -3674,7 +3674,7 @@ tSCC* apzDarwin_Flt_Eval_MethodMachs[] = { - * content selection pattern - do fix if pattern found - */ - tSCC zDarwin_Flt_Eval_MethodSelect0[] = -- "^#if __FLT_EVAL_METHOD__ == 0$"; -+ "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$"; - - #define DARWIN_FLT_EVAL_METHOD_TEST_CT 1 - static tTestDesc aDarwin_Flt_Eval_MethodTests[] = { -@@ -3685,7 +3685,7 @@ static tTestDesc aDarwin_Flt_Eval_MethodTests[] = { - */ - static const char* apzDarwin_Flt_Eval_MethodPatch[] = { - "format", -- "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16", -+ "%0 || __FLT_EVAL_METHOD__ == 16", - (char*)NULL }; - - /* * * * * * * * * * * * * * * * * * * * * * * * * * -diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def -index 45e0cbc0c10..19e0ea2df66 100644 ---- a/fixincludes/inclhack.def -+++ b/fixincludes/inclhack.def -@@ -1819,10 +1819,11 @@ fix = { - hackname = darwin_flt_eval_method; - mach = "*-*-darwin*"; - files = math.h; -- select = "^#if __FLT_EVAL_METHOD__ == 0$"; -+ select = "^#if __FLT_EVAL_METHOD__ == 0( \\|\\| __FLT_EVAL_METHOD__ == -1)?$"; - c_fix = format; -- c_fix_arg = "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16"; -- test_text = "#if __FLT_EVAL_METHOD__ == 0"; -+ c_fix_arg = "%0 || __FLT_EVAL_METHOD__ == 16"; -+ test_text = "#if __FLT_EVAL_METHOD__ == 0\n" -+ "#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1"; - }; - - /* -diff --git a/fixincludes/tests/base/math.h b/fixincludes/tests/base/math.h -index 29b67579748..7b92f29a409 100644 ---- a/fixincludes/tests/base/math.h -+++ b/fixincludes/tests/base/math.h -@@ -32,6 +32,7 @@ - - #if defined( DARWIN_FLT_EVAL_METHOD_CHECK ) - #if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 16 -+#if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1 || __FLT_EVAL_METHOD__ == 16 - #endif /* DARWIN_FLT_EVAL_METHOD_CHECK */ - - --- -2.39.3 From 72fd0285f3a3a69ae3eb5ac34e660c6b1d44f8d9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 27 Jul 2024 17:18:56 -0700 Subject: [PATCH 51/91] build/pkgs/gcc/patches: Add https://raw.githubusercontent.com/Homebrew/formula-patches/bda0faddfbfb392e7b9c9101056b2c5ab2500508/gcc/gcc-13.3.0.diff --- ...-13.2.0-arm.patch => gcc-13.3.0-arm.patch} | 6303 ++++++++++++----- 1 file changed, 4585 insertions(+), 1718 deletions(-) rename build/pkgs/gcc/patches/{gcc-13.2.0-arm.patch => gcc-13.3.0-arm.patch} (70%) diff --git a/build/pkgs/gcc/patches/gcc-13.2.0-arm.patch b/build/pkgs/gcc/patches/gcc-13.3.0-arm.patch similarity index 70% rename from build/pkgs/gcc/patches/gcc-13.2.0-arm.patch rename to build/pkgs/gcc/patches/gcc-13.3.0-arm.patch index 0a3688f7d90..56919f9e959 100644 --- a/build/pkgs/gcc/patches/gcc-13.2.0-arm.patch +++ b/build/pkgs/gcc/patches/gcc-13.3.0-arm.patch @@ -13,7 +13,7 @@ index 35e994eb77e..9b4a8a2bf7a 100644 // Work around in-tree gmp configure bug with missing flex. extra_configure_flags='--disable-shared LEX="touch lex.yy.c" @host_libs_picflag@'; diff --git a/Makefile.in b/Makefile.in -index 06a9398e172..0973ec3a71d 100644 +index 205d3c30bde..fdfd3d75593 100644 --- a/Makefile.in +++ b/Makefile.in @@ -12016,7 +12016,7 @@ configure-gcc: @@ -115,9 +115,6 @@ index 06a9398e172..0973ec3a71d 100644 @endif gcc-bootstrap -diff --git a/aclocal.m4 b/aclocal.m4 -new file mode 100644 -index 00000000000..e69de29bb2d diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in index 77bda3d56dc..dcb1029e064 100644 --- a/c++tools/Makefile.in @@ -227,7 +224,7 @@ index 23e98c8e721..44dfaccbbfa 100644 # Check if O_CLOEXEC is defined by fcntl AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [ diff --git a/configure b/configure -index 117a7ef23f2..ee9dd18d2a3 100755 +index 117a7ef23f2..c721ee4b5b2 100755 --- a/configure +++ b/configure @@ -687,7 +687,10 @@ extra_host_zlib_configure_flags @@ -257,7 +254,16 @@ index 117a7ef23f2..ee9dd18d2a3 100755 --enable-host-shared build host code as shared libraries --enable-stage1-languages[=all] choose additional languages to build during stage1. -@@ -8414,6 +8419,20 @@ else +@@ -3451,6 +3456,8 @@ esac + + # Disable libffi for some systems. + case "${target}" in ++ aarch64*-*-darwin2*) ++ ;; + powerpc-*-darwin*) + ;; + i[3456789]86-*-darwin*) +@@ -8414,6 +8421,20 @@ else fi fi @@ -278,7 +284,7 @@ index 117a7ef23f2..ee9dd18d2a3 100755 # GCC GRAPHITE dependency isl. -@@ -8645,6 +8664,39 @@ fi +@@ -8645,6 +8666,39 @@ fi @@ -318,7 +324,7 @@ index 117a7ef23f2..ee9dd18d2a3 100755 # Enable --enable-host-shared. # Checked early to determine whether jit is an 'all' language # Check whether --enable-host-shared was given. -@@ -8654,26 +8706,57 @@ if test "${enable_host_shared+set}" = set; then : +@@ -8654,26 +8708,57 @@ if test "${enable_host_shared+set}" = set; then : x86_64-*-darwin* | aarch64-*-darwin*) if test x$host_shared != xyes ; then # PIC is the default, and actually cannot be switched off. @@ -380,10 +386,19 @@ index 117a7ef23f2..ee9dd18d2a3 100755 fi diff --git a/configure.ac b/configure.ac -index b3e9bbd2aa5..4d390f86c7e 100644 +index b3e9bbd2aa5..a75c9e8850c 100644 --- a/configure.ac +++ b/configure.ac -@@ -1806,6 +1806,20 @@ AC_ARG_WITH(boot-ldflags, +@@ -710,6 +710,8 @@ esac + + # Disable libffi for some systems. + case "${target}" in ++ aarch64*-*-darwin2*) ++ ;; + powerpc-*-darwin*) + ;; + i[[3456789]]86-*-darwin*) +@@ -1806,6 +1808,20 @@ AC_ARG_WITH(boot-ldflags, if test "$poststage1_libs" = ""; then poststage1_ldflags="-static-libstdc++ -static-libgcc" fi]) @@ -404,7 +419,7 @@ index b3e9bbd2aa5..4d390f86c7e 100644 AC_SUBST(poststage1_ldflags) # GCC GRAPHITE dependency isl. -@@ -1891,6 +1905,36 @@ AC_ARG_ENABLE(linker-plugin-flags, +@@ -1891,6 +1907,36 @@ AC_ARG_ENABLE(linker-plugin-flags, extra_linker_plugin_flags=) AC_SUBST(extra_linker_plugin_flags) @@ -441,7 +456,7 @@ index b3e9bbd2aa5..4d390f86c7e 100644 # Enable --enable-host-shared. # Checked early to determine whether jit is an 'all' language AC_ARG_ENABLE(host-shared, -@@ -1901,23 +1945,52 @@ AC_ARG_ENABLE(host-shared, +@@ -1901,23 +1947,52 @@ AC_ARG_ENABLE(host-shared, x86_64-*-darwin* | aarch64-*-darwin*) if test x$host_shared != xyes ; then # PIC is the default, and actually cannot be switched off. @@ -542,7 +557,7 @@ index 1937dcaa32d..e6ce41dba39 100644 $(ALLOBJ) : $(HDR) fixincl.o : fixincl.c $(srcdir)/fixincl.x diff --git a/fixincludes/configure b/fixincludes/configure -index bdcc41f6ddc..a5e995f5316 100755 +index bdcc41f6ddc..b2759ee3b98 100755 --- a/fixincludes/configure +++ b/fixincludes/configure @@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS @@ -570,15 +585,7 @@ index bdcc41f6ddc..a5e995f5316 100755 --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer -@@ -3022,6 +3026,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - # --------------------------- - # _LT_COMPILER_PIC - -+enable_darwin_at_rpath_$1=no - - # _LT_LINKER_SHLIBS([TAGNAME]) - # ---------------------------- -@@ -3044,7 +3049,6 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. +@@ -3044,7 +3048,6 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # the compiler configuration to `libtool'. # _LT_LANG_CXX_CONFIG @@ -586,7 +593,7 @@ index bdcc41f6ddc..a5e995f5316 100755 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose -@@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h +@@ -4835,6 +4838,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h fi @@ -622,7 +629,7 @@ index ef2227e3c93..4e78511d20f 100644 vax-dec-bsd* ) AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit]) diff --git a/gcc/Makefile.in b/gcc/Makefile.in -index 775aaa1b3c4..2b0d8f9cd01 100644 +index 775aaa1b3c4..740199cb36f 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -158,6 +158,9 @@ LDFLAGS = @LDFLAGS@ @@ -730,7 +737,7 @@ index 775aaa1b3c4..2b0d8f9cd01 100644 echo "set COMPAT_OPTIONS \"$(COMPAT_OPTIONS)\"" >> ./site.tmp; \ else true; \ fi -+ @if test "x@enable_darwin_at_rpath@" = "xyes" ; then \ ++ @if test "X@ENABLE_DARWIN_AT_RPATH_TRUE@" != "X#" ; then \ + echo "set ENABLE_DARWIN_AT_RPATH 1" >> ./site.tmp; \ + fi @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./site.tmp @@ -880,19 +887,327 @@ index da6a56fcec8..51a4bf17038 100644 $(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \ libgnat$(soext) +diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc +index 4389ff917b8..0fe5d2a2e67 100644 +--- a/gcc/analyzer/kf.cc ++++ b/gcc/analyzer/kf.cc +@@ -1081,7 +1081,7 @@ register_known_functions (known_function_manager &kfm) + like this: + extern int *___errno(void) __attribute__((__const__)); + #define errno (*(___errno())) +- and OS X like this: ++ and macOS like this: + extern int * __error(void); + #define errno (*__error()) + and similarly __errno for newlib. +diff --git a/gcc/builtins.cc b/gcc/builtins.cc +index 1bfdc598eec..1122527cbd7 100644 +--- a/gcc/builtins.cc ++++ b/gcc/builtins.cc +@@ -5501,6 +5501,13 @@ expand_builtin_trap (void) + static void + expand_builtin_unreachable (void) + { ++ /* If the target wants a trap in place of the fall-through, use that. */ ++ if (targetm.unreachable_should_trap ()) ++ { ++ expand_builtin_trap (); ++ return; ++ } ++ + /* Use gimple_build_builtin_unreachable or builtin_decl_unreachable + to avoid this. */ + gcc_checking_assert (!sanitize_flags_p (SANITIZE_UNREACHABLE)); +@@ -7958,6 +7965,10 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, + case BUILT_IN_ADJUST_DESCRIPTOR: + return expand_builtin_adjust_descriptor (exp); + ++ case BUILT_IN_GCC_NESTED_PTR_CREATED: ++ case BUILT_IN_GCC_NESTED_PTR_DELETED: ++ break; /* At present, no expansion, just call the function. */ ++ + case BUILT_IN_FORK: + case BUILT_IN_EXECL: + case BUILT_IN_EXECV: diff --git a/gcc/builtins.def b/gcc/builtins.def -index 4ad95a12f83..922219963e3 100644 +index 4ad95a12f83..448cf837ec8 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -1067,6 +1067,8 @@ DEF_BUILTIN_STUB (BUILT_IN_ADJUST_TRAMPOLINE, "__builtin_adjust_trampoline") DEF_BUILTIN_STUB (BUILT_IN_INIT_DESCRIPTOR, "__builtin_init_descriptor") DEF_BUILTIN_STUB (BUILT_IN_ADJUST_DESCRIPTOR, "__builtin_adjust_descriptor") DEF_BUILTIN_STUB (BUILT_IN_NONLOCAL_GOTO, "__builtin_nonlocal_goto") -+DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_CREATED, "__builtin_nested_func_ptr_created") -+DEF_BUILTIN_STUB (BUILT_IN_NESTED_PTR_DELETED, "__builtin_nested_func_ptr_deleted") ++DEF_EXT_LIB_BUILTIN (BUILT_IN_GCC_NESTED_PTR_CREATED, "__gcc_nested_func_ptr_created", BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LIST) ++DEF_EXT_LIB_BUILTIN (BUILT_IN_GCC_NESTED_PTR_DELETED, "__gcc_nested_func_ptr_deleted", BT_FN_VOID, ATTR_NOTHROW_LIST) /* Implementing __builtin_setjmp. */ DEF_BUILTIN_STUB (BUILT_IN_SETJMP_SETUP, "__builtin_setjmp_setup") +diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc +index 67709912a11..a0adac162e9 100644 +--- a/gcc/c-family/c-attribs.cc ++++ b/gcc/c-family/c-attribs.cc +@@ -607,6 +607,18 @@ attribute_takes_identifier_p (const_tree attr_id) + return targetm.attribute_takes_identifier_p (attr_id); + } + ++/* Returns TRUE iff the attribute indicated by ATTR_ID needs its ++ arguments converted to string constants. */ ++ ++bool ++attribute_clang_form_p (const_tree attr_id) ++{ ++ const struct attribute_spec *spec = lookup_attribute_spec (attr_id); ++ if (spec && !strcmp ("availability", spec->name)) ++ return true; ++ return false; ++} ++ + /* Verify that argument value POS at position ARGNO to attribute NAME + applied to function FN (which is either a function declaration or function + type) refers to a function parameter at position POS and the expected type +diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc +index 303d7f1ef5d..e3c3fae8dea 100644 +--- a/gcc/c-family/c-common.cc ++++ b/gcc/c-family/c-common.cc +@@ -311,6 +311,44 @@ const struct fname_var_t fname_vars[] = + {NULL, 0, 0}, + }; + ++/* Flags to restrict availability of generic features that ++ are known to __has_{feature,extension}. */ ++ ++enum ++{ ++ HF_FLAG_NONE = 0, ++ HF_FLAG_EXT = 1, /* Available only as an extension. */ ++ HF_FLAG_SANITIZE = 2, /* Availability depends on sanitizer flags. */ ++}; ++ ++/* Info for generic features which can be queried through ++ __has_{feature,extension}. */ ++ ++struct hf_feature_info ++{ ++ const char *ident; ++ unsigned flags; ++ unsigned mask; ++}; ++ ++/* Table of generic features which can be queried through ++ __has_{feature,extension}. */ ++ ++static constexpr hf_feature_info has_feature_table[] = ++{ ++ { "address_sanitizer", HF_FLAG_SANITIZE, SANITIZE_ADDRESS }, ++ { "thread_sanitizer", HF_FLAG_SANITIZE, SANITIZE_THREAD }, ++ { "leak_sanitizer", HF_FLAG_SANITIZE, SANITIZE_LEAK }, ++ { "hwaddress_sanitizer", HF_FLAG_SANITIZE, SANITIZE_HWADDRESS }, ++ { "undefined_behavior_sanitizer", HF_FLAG_SANITIZE, SANITIZE_UNDEFINED }, ++ { "attribute_deprecated_with_message", HF_FLAG_NONE, 0 }, ++ { "attribute_unavailable_with_message", HF_FLAG_NONE, 0 }, ++ { "enumerator_attributes", HF_FLAG_NONE, 0 }, ++ { "tls", HF_FLAG_NONE, 0 }, ++ { "gnu_asm_goto_with_outputs", HF_FLAG_EXT, 0 }, ++ { "gnu_asm_goto_with_outputs_full", HF_FLAG_EXT, 0 } ++}; ++ + /* Global visibility options. */ + struct visibility_flags visibility_options; + +@@ -9552,4 +9590,63 @@ c_strict_flex_array_level_of (tree array_field) + return strict_flex_array_level; + } + ++/* Map from identifiers to booleans. Value is true for features, and ++ false for extensions. Used to implement __has_{feature,extension}. */ ++ ++using feature_map_t = hash_map ; ++static feature_map_t *feature_map; ++ ++/* Register a feature for __has_{feature,extension}. FEATURE_P is true ++ if the feature identified by NAME is a feature (as opposed to an ++ extension). */ ++ ++void ++c_common_register_feature (const char *name, bool feature_p) ++{ ++ bool dup = feature_map->put (get_identifier (name), feature_p); ++ gcc_checking_assert (!dup); ++} ++ ++/* Lazily initialize hash table for __has_{feature,extension}, ++ dispatching to the appropriate front end to register language-specific ++ features. */ ++ ++static void ++init_has_feature () ++{ ++ gcc_checking_assert (!feature_map); ++ feature_map = new feature_map_t; ++ ++ for (unsigned i = 0; i < ARRAY_SIZE (has_feature_table); i++) ++ { ++ const hf_feature_info *info = has_feature_table + i; ++ ++ if ((info->flags & HF_FLAG_SANITIZE) && !(flag_sanitize & info->mask)) ++ continue; ++ ++ const bool feature_p = !(info->flags & HF_FLAG_EXT); ++ c_common_register_feature (info->ident, feature_p); ++ } ++ ++ /* Register language-specific features. */ ++ c_family_register_lang_features (); ++} ++ ++/* If STRICT_P is true, evaluate __has_feature (IDENT). ++ Otherwise, evaluate __has_extension (IDENT). */ ++ ++bool ++has_feature_p (const char *ident, bool strict_p) ++{ ++ if (!feature_map) ++ init_has_feature (); ++ ++ tree name = canonicalize_attr_name (get_identifier (ident)); ++ bool *feat_p = feature_map->get (name); ++ if (!feat_p) ++ return false; ++ ++ return !strict_p || *feat_p; ++} ++ + #include "gt-c-family-c-common.h" +diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h +index f96350b64af..41d69d45ea6 100644 +--- a/gcc/c-family/c-common.h ++++ b/gcc/c-family/c-common.h +@@ -1121,6 +1121,14 @@ extern bool c_cpp_diagnostic (cpp_reader *, enum cpp_diagnostic_level, + ATTRIBUTE_GCC_DIAG(5,0); + extern int c_common_has_attribute (cpp_reader *, bool); + extern int c_common_has_builtin (cpp_reader *); ++extern int c_common_has_feature (cpp_reader *, bool); ++ ++/* Implemented by each front end in *-lang.cc. */ ++extern void c_family_register_lang_features (); ++ ++/* Implemented in c-family/c-common.cc. */ ++extern void c_common_register_feature (const char *, bool); ++extern bool has_feature_p (const char *, bool); + + extern bool parse_optimize_options (tree, bool); + +@@ -1529,6 +1537,7 @@ extern void check_for_xor_used_as_pow (location_t lhs_loc, tree lhs_val, + /* In c-attribs.cc. */ + extern bool attribute_takes_identifier_p (const_tree); + extern tree handle_deprecated_attribute (tree *, tree, tree, int, bool *); ++extern bool attribute_clang_form_p (const_tree); + extern tree handle_unused_attribute (tree *, tree, tree, int, bool *); + extern tree handle_fallthrough_attribute (tree *, tree, tree, int, bool *); + extern int parse_tm_stmt_attr (tree, int); +diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc +index 0acfdaa95c9..2a504a98edf 100644 +--- a/gcc/c-family/c-lex.cc ++++ b/gcc/c-family/c-lex.cc +@@ -82,6 +82,7 @@ init_c_lex (void) + cb->read_pch = c_common_read_pch; + cb->has_attribute = c_common_has_attribute; + cb->has_builtin = c_common_has_builtin; ++ cb->has_feature = c_common_has_feature; + cb->get_source_date_epoch = cb_get_source_date_epoch; + cb->get_suggestion = cb_get_suggestion; + cb->remap_filename = remap_macro_filename; +@@ -457,16 +458,16 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) + return result; + } + +-/* Callback for has_builtin. */ ++/* Helper for __has_{builtin,feature,extension}. */ + +-int +-c_common_has_builtin (cpp_reader *pfile) ++static const char * ++c_common_lex_availability_macro (cpp_reader *pfile, const char *builtin) + { + const cpp_token *token = get_token_no_padding (pfile); + if (token->type != CPP_OPEN_PAREN) + { + cpp_error (pfile, CPP_DL_ERROR, +- "missing '(' after \"__has_builtin\""); ++ "missing '(' after \"__has_%s\"", builtin); + return 0; + } + +@@ -486,7 +487,7 @@ c_common_has_builtin (cpp_reader *pfile) + else + { + cpp_error (pfile, CPP_DL_ERROR, +- "macro \"__has_builtin\" requires an identifier"); ++ "macro \"__has_%s\" requires an identifier", builtin); + if (token->type == CPP_CLOSE_PAREN) + return 0; + } +@@ -505,9 +506,38 @@ c_common_has_builtin (cpp_reader *pfile) + break; + } + ++ return name; ++} ++ ++/* Callback for has_builtin. */ ++ ++int ++c_common_has_builtin (cpp_reader *pfile) ++{ ++ const char *name = c_common_lex_availability_macro (pfile, "builtin"); ++ if (!name) ++ return 0; ++ + return names_builtin_p (name); + } + ++/* Callback for has_feature. STRICT_P is true for has_feature and false ++ for has_extension. */ ++ ++int ++c_common_has_feature (cpp_reader *pfile, bool strict_p) ++{ ++ const char *builtin = strict_p ? "feature" : "extension"; ++ const char *name = c_common_lex_availability_macro (pfile, builtin); ++ if (!name) ++ return 0; ++ ++ /* If -pedantic-errors is given, __has_extension is equivalent to ++ __has_feature. */ ++ strict_p |= flag_pedantic_errors; ++ return has_feature_p (name, strict_p); ++} ++ + + /* Read a token and return its type. Fill *VALUE with its value, if + applicable. Fill *CPP_FLAGS with the token's flags, if it is +@@ -539,6 +569,21 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, + + case CPP_NUMBER: + { ++ /* If the user wants number-like entities to be returned as a raw ++ string, then don't try to classify them, which emits unwanted ++ diagnostics. */ ++ if (lex_flags & C_LEX_NUMBER_AS_STRING) ++ { ++ /* build_string adds a trailing NUL at [len]. */ ++ tree num_string = build_string (tok->val.str.len + 1, ++ (const char *) tok->val.str.text); ++ TREE_TYPE (num_string) = char_array_type_node; ++ *value = num_string; ++ /* We will effectively note this as CPP_N_INVALID, because we ++ made no checks here. */ ++ break; ++ } ++ + const char *suffix = NULL; + unsigned int flags = cpp_classify_number (parse_in, tok, &suffix, *loc); + diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index c68a2a27469..a600d40c87e 100644 --- a/gcc/c-family/c-opts.cc @@ -906,8 +1221,268 @@ index c68a2a27469..a600d40c87e 100644 { /* Lazy TLS initialization for a variable in another TU requires alias and weak reference support. */ +diff --git a/gcc/c-family/c-ppoutput.cc b/gcc/c-family/c-ppoutput.cc +index 4aa2bef2c0f..a1488c6f086 100644 +--- a/gcc/c-family/c-ppoutput.cc ++++ b/gcc/c-family/c-ppoutput.cc +@@ -162,6 +162,7 @@ init_pp_output (FILE *out_stream) + + cb->has_attribute = c_common_has_attribute; + cb->has_builtin = c_common_has_builtin; ++ cb->has_feature = c_common_has_feature; + cb->get_source_date_epoch = cb_get_source_date_epoch; + cb->remap_filename = remap_macro_filename; + +diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h +index 9cc95ab3ee3..3e86a16d4ae 100644 +--- a/gcc/c-family/c-pragma.h ++++ b/gcc/c-family/c-pragma.h +@@ -272,6 +272,9 @@ extern enum cpp_ttype pragma_lex (tree *, location_t *loc = NULL); + #define C_LEX_STRING_NO_JOIN 2 /* Do not concatenate strings + nor translate them into execution + character set. */ ++#define C_LEX_NUMBER_AS_STRING 4 /* Do not classify a number, but ++ instead return it as a raw ++ string. */ + + /* This is not actually available to pragma parsers. It's merely a + convenient location to declare this function for c-lex, after +diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt +index a75038930ae..c7e662018d5 100644 +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -1484,6 +1484,10 @@ Wsubobject-linkage + C++ ObjC++ Var(warn_subobject_linkage) Warning Init(1) + Warn if a class type has a base or a field whose type uses the anonymous namespace or depends on a type with no linkage. + ++Welaborated-enum-base ++C++ ObjC++ Var(warn_elaborated_enum_base) Warning Init(1) ++Warn if an additional enum-base is used in an elaborated-type-specifier. ++ + Wduplicate-decl-specifier + C ObjC Var(warn_duplicate_decl_specifier) Warning LangEnabledBy(C ObjC,Wall) + Warn when a declaration has duplicate const, volatile, restrict or _Atomic specifier. +@@ -1967,7 +1971,7 @@ Implement resolution of DR 150 for matching of template template arguments. + + fnext-runtime + ObjC ObjC++ LTO RejectNegative Var(flag_next_runtime) +-Generate code for NeXT (Apple Mac OS X) runtime environment. ++Generate code for NeXT (Apple macOS) runtime environment. + + fnil-receivers + ObjC ObjC++ Var(flag_nil_receivers) Init(1) +diff --git a/gcc/c/c-lang.cc b/gcc/c/c-lang.cc +index b4e0c8cfb8a..11e7aaac2e3 100644 +--- a/gcc/c/c-lang.cc ++++ b/gcc/c/c-lang.cc +@@ -61,6 +61,15 @@ c_get_sarif_source_language (const char *) + return "c"; + } + ++/* Implement c-family hook to register language-specific features for ++ __has_{feature,extension}. */ ++ ++void ++c_family_register_lang_features () ++{ ++ c_register_features (); ++} ++ + #if CHECKING_P + + namespace selftest { +diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc +index e4aed61ed00..fad46626570 100644 +--- a/gcc/c/c-objc-common.cc ++++ b/gcc/c/c-objc-common.cc +@@ -34,6 +34,38 @@ along with GCC; see the file COPYING3. If not see + static bool c_tree_printer (pretty_printer *, text_info *, const char *, + int, bool, bool, bool, bool *, const char **); + ++/* Info for C language features which can be queried through ++ __has_{feature,extension}. */ ++ ++struct c_feature_info ++{ ++ const char *ident; ++ const int *enable_flag; ++}; ++ ++static const c_feature_info c_feature_table[] = ++{ ++ { "c_alignas", &flag_isoc11 }, ++ { "c_alignof", &flag_isoc11 }, ++ { "c_atomic", &flag_isoc11 }, ++ { "c_generic_selections", &flag_isoc11 }, ++ { "c_static_assert", &flag_isoc11 }, ++ { "c_thread_local", &flag_isoc11 } ++}; ++ ++/* Register features specific to the C language. */ ++ ++void ++c_register_features () ++{ ++ for (unsigned i = 0; i < ARRAY_SIZE (c_feature_table); i++) ++ { ++ const c_feature_info *info = c_feature_table + i; ++ const bool feat_p = !info->enable_flag || *info->enable_flag; ++ c_common_register_feature (info->ident, feat_p); ++ } ++} ++ + bool + c_missing_noreturn_ok_p (tree decl) + { +diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h +index d31dacb9dd4..34dc23a1bd0 100644 +--- a/gcc/c/c-objc-common.h ++++ b/gcc/c/c-objc-common.h +@@ -21,6 +21,9 @@ along with GCC; see the file COPYING3. If not see + #ifndef GCC_C_OBJC_COMMON + #define GCC_C_OBJC_COMMON + ++/* Implemented in c-objc-common.cc. */ ++extern void c_register_features (); ++ + /* Lang hooks that are shared between C and ObjC are defined here. Hooks + specific to C or ObjC go in c-lang.cc and objc/objc-lang.cc, respectively. */ + +diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc +index 3627a3fbdc7..5abc6e84697 100644 +--- a/gcc/c/c-parser.cc ++++ b/gcc/c/c-parser.cc +@@ -217,6 +217,9 @@ struct GTY(()) c_parser { + should translate them to the execution character set (false + inside attributes). */ + BOOL_BITFIELD translate_strings_p : 1; ++ /* True if we want to lex arbitrary number-like sequences as their ++ string representation. */ ++ BOOL_BITFIELD lex_number_as_string : 1; + + /* Objective-C specific parser/lexer information. */ + +@@ -291,10 +294,10 @@ c_lex_one_token (c_parser *parser, c_token *token, bool raw = false) + + if (raw || vec_safe_length (parser->raw_tokens) == 0) + { ++ int lex_flags = parser->lex_joined_string ? 0 : C_LEX_STRING_NO_JOIN; ++ lex_flags |= parser->lex_number_as_string ? C_LEX_NUMBER_AS_STRING : 0; + token->type = c_lex_with_flags (&token->value, &token->location, +- &token->flags, +- (parser->lex_joined_string +- ? 0 : C_LEX_STRING_NO_JOIN)); ++ &token->flags, lex_flags); + token->id_kind = C_ID_NONE; + token->keyword = RID_MAX; + token->pragma_kind = PRAGMA_NONE; +@@ -4993,6 +4996,88 @@ c_parser_gnu_attribute_any_word (c_parser *parser) + return attr_name; + } + ++/* Handle parsing clang-form attribute arguments, where we need to adjust ++ the parsing rules to relate to a specific attribute. */ ++ ++static tree ++c_parser_clang_attribute_arguments (c_parser *parser, tree /*attr_id*/) ++{ ++ /* We can, if required, alter the parsing on the basis of the attribute. ++ At present, we handle the availability attr, where ach entry can be : ++ identifier ++ identifier=N.MM.Z ++ identifier="string" ++ followed by ',' or ) for the last entry*/ ++ ++ tree attr_args = NULL_TREE; ++ do ++ { ++ tree name = NULL_TREE; ++ tree value = NULL_TREE; ++ ++ if (c_parser_next_token_is (parser, CPP_NAME) ++ && c_parser_peek_token (parser)->id_kind == C_ID_ID) ++ { ++ name = c_parser_peek_token (parser)->value; ++ c_parser_consume_token (parser); ++ } ++ else if (c_parser_next_token_is (parser, CPP_COMMA)) ++ name = error_mark_node; /* Comma handled below. */ ++ else ++ { ++ bool saved_join_state = parser->lex_joined_string; ++ parser->lex_number_as_string = 1; ++ parser->lex_joined_string = 1; ++ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, ++ "expected an attribute keyword"); ++ parser->lex_number_as_string = 0; ++ parser->lex_joined_string = saved_join_state; ++ return error_mark_node; ++ } ++ if (c_parser_next_token_is (parser, CPP_EQ)) ++ { ++ c_parser_consume_token (parser); /* eat the '=' */ ++ /* We need to bludgeon the lexer into not trying to interpret the ++ xx.yy.zz form, since that just looks like a malformed float. ++ Also, as a result of macro processing, we can have strig literals ++ that are in multiple pieces so, for this specific part of the ++ parse, we need to join strings. */ ++ bool saved_join_state = parser->lex_joined_string; ++ parser->lex_number_as_string = 1; ++ parser->lex_joined_string = 1; ++ /* So look at the next token, expecting a string, or something that ++ looks initially like a number, but might be a version number. */ ++ c_parser_peek_token (parser); ++ /* Done with the funky number parsing. */ ++ parser->lex_number_as_string = 0; ++ parser->lex_joined_string = saved_join_state; ++ if (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN) ++ && c_parser_next_token_is_not (parser, CPP_COMMA)) ++ { ++ value = c_parser_peek_token (parser)->value; ++ /* ???: check for error mark and early-return? */ ++ c_parser_consume_token (parser); ++ } ++ /* else value is absent. */ ++ } ++ else if (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN) ++ && c_parser_next_token_is_not (parser, CPP_COMMA)) ++ { ++ c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, ++ "expected %<,%> or %<=%>"); ++ return error_mark_node; ++ } ++ if (c_parser_next_token_is (parser, CPP_COMMA)) ++ c_parser_consume_token (parser); /* Just skip the comma. */ ++ tree t = tree_cons (value, name, NULL); ++ if (!attr_args) ++ attr_args = t; ++ else ++ chainon (attr_args, t); ++ } while (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN)); ++ return attr_args; ++} ++ + /* Parse attribute arguments. This is a common form of syntax + covering all currently valid GNU and standard attributes. + +@@ -5158,9 +5243,13 @@ c_parser_gnu_attribute (c_parser *parser, tree attrs, + attrs = chainon (attrs, attr); + return attrs; + } +- c_parser_consume_token (parser); ++ c_parser_consume_token (parser); /* The '('. */ + +- tree attr_args ++ tree attr_args; ++ if (attribute_clang_form_p (attr_name)) ++ attr_args = c_parser_clang_attribute_arguments (parser, attr_name); ++ else ++ attr_args + = c_parser_attribute_arguments (parser, + attribute_takes_identifier_p (attr_name), + false, diff --git a/gcc/calls.cc b/gcc/calls.cc -index 4d7f6c3d291..cc8594a04e8 100644 +index 53b0f58b709..b58990f1b90 100644 --- a/gcc/calls.cc +++ b/gcc/calls.cc @@ -1367,7 +1367,8 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, @@ -920,7 +1495,25 @@ index 4d7f6c3d291..cc8594a04e8 100644 if (pass_by_reference (args_so_far_pnt, arg)) { const bool callee_copies -@@ -1540,6 +1541,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, +@@ -1487,10 +1488,13 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, + + unsignedp = TYPE_UNSIGNED (type); + arg.type = type; +- arg.mode +- = promote_function_mode (type, TYPE_MODE (type), &unsignedp, +- fndecl ? TREE_TYPE (fndecl) : fntype, 0); +- ++ arg.mode = TYPE_MODE (type); ++// arg.mode ++// = promote_function_mode (type, TYPE_MODE (type), &unsignedp, ++// fndecl ? TREE_TYPE (fndecl) : fntype, 0); ++ arg.mode = promote_function_mode (args_so_far, arg, ++ fndecl ? TREE_TYPE (fndecl) : fntype, ++ &unsignedp, 0); + args[i].unsignedp = unsignedp; + args[i].mode = arg.mode; + +@@ -1540,6 +1544,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, #endif reg_parm_stack_space, args[i].pass_on_stack ? 0 : args[i].partial, @@ -928,7 +1521,15 @@ index 4d7f6c3d291..cc8594a04e8 100644 fndecl, args_size, &args[i].locate); #ifdef BLOCK_REG_PADDING else -@@ -4260,6 +4262,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, +@@ -4076,6 +4081,7 @@ split_complex_types (tree types) + return types; + } + ++extern void debug_tree (tree); + /* Output a library call to function ORGFUN (a SYMBOL_REF rtx) + for a value of mode OUTMODE, + with NARGS different arguments, passed as ARGS. +@@ -4261,6 +4267,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, argvec[count].reg != 0, #endif reg_parm_stack_space, 0, @@ -936,7 +1537,26 @@ index 4d7f6c3d291..cc8594a04e8 100644 NULL_TREE, &args_size, &argvec[count].locate); if (argvec[count].reg == 0 || argvec[count].partial != 0 -@@ -4351,6 +4354,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, +@@ -4331,8 +4338,16 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, + val = force_operand (XEXP (slot, 0), NULL_RTX); + } + +- arg.mode = promote_function_mode (NULL_TREE, arg.mode, &unsigned_p, +- NULL_TREE, 0); ++// arg.mode = promote_function_mode (NULL_TREE, arg.mode, &unsigned_p, ++// NULL_TREE, 0); ++ tree t = arg.type; ++if (t) ++ debug_tree (t); ++gcc_assert (!t); ++ arg.type = NULL_TREE; ++ arg.mode = promote_function_mode (args_so_far, arg, NULL_TREE, ++ &unsigned_p, 0); ++ arg.type = t; + argvec[count].mode = arg.mode; + argvec[count].value = convert_modes (arg.mode, GET_MODE (val), val, + unsigned_p); +@@ -4352,6 +4367,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, argvec[count].reg != 0, #endif reg_parm_stack_space, argvec[count].partial, @@ -1006,22 +1626,119 @@ index c7f8c5e4b39..42a1774fe84 100644 /* True if we have decided to pass the argument by reference, in which case the function_arg_info describes a pointer to the original argument. */ unsigned int pass_by_reference : 1; -diff --git a/gcc/common.opt b/gcc/common.opt -index 862c474d3c8..1277203d550 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -2212,6 +2212,10 @@ foffload-abi= - Common Joined RejectNegative Enum(offload_abi) - -foffload-abi=[lp64|ilp32] Set the ABI to use in an offload compiler. +diff --git a/gcc/collect2.cc b/gcc/collect2.cc +index 63b9a0c233a..1d7d9a442ac 100644 +--- a/gcc/collect2.cc ++++ b/gcc/collect2.cc +@@ -73,7 +73,7 @@ along with GCC; see the file COPYING3. If not see + In a cross-compiler, this means you need a cross nm, + but that is not quite as unpleasant as special headers. */ + +-#if !defined (OBJECT_FORMAT_COFF) ++#if !defined (OBJECT_FORMAT_COFF) && !defined (OBJECT_FORMAT_MACHO) + #define OBJECT_FORMAT_NONE + #endif + +@@ -107,7 +107,7 @@ along with GCC; see the file COPYING3. If not see + + #endif /* OBJECT_FORMAT_COFF */ + +-#ifdef OBJECT_FORMAT_NONE ++#if defined (OBJECT_FORMAT_NONE) || defined (OBJECT_FORMAT_MACHO) -+foff-stack-trampolines -+Common RejectNegative Var(flag_off_stack_trampolines) Init(OFF_STACK_TRAMPOLINES_INIT) -+Generate trampolines in executable memory rather than executable stack. + /* Default flags to pass to nm. */ + #ifndef NM_FLAGS +@@ -525,7 +525,7 @@ static const char *const target_machine = TARGET_MACHINE; + + Return 0 if not found, otherwise return its name, allocated with malloc. */ + +-#ifdef OBJECT_FORMAT_NONE ++#if defined (OBJECT_FORMAT_NONE) || defined (OBJECT_FORMAT_MACHO) + + /* Add an entry for the object file NAME to object file list LIST. + New entries are added at the end of the list. The original pointer +@@ -764,6 +764,12 @@ do_link (char **ld_argv, const char *atsuffix) + } + } + ++#if defined (OBJECT_FORMAT_MACHO) ++# define LLD_NAME "ld64.lld" ++#else ++# define LLD_NAME "ld.lld" ++#endif + - Enum - Name(offload_abi) Type(enum offload_abi) UnknownError(unknown offload ABI %qs) + /* Main program. */ + + int +@@ -777,16 +783,19 @@ main (int argc, char **argv) + USE_BFD_LD, + USE_LLD_LD, + USE_MOLD_LD, ++ USE_CLASSIC_LD, + USE_LD_MAX + } selected_linker = USE_DEFAULT_LD; ++ + static const char *const ld_suffixes[USE_LD_MAX] = + { + "ld", + PLUGIN_LD_SUFFIX, + "ld.gold", + "ld.bfd", +- "ld.lld", +- "ld.mold" ++ LLD_NAME, ++ "ld.mold", ++ "ld-classic" + }; + static const char *const real_ld_suffix = "real-ld"; + static const char *const collect_ld_suffix = "collect-ld"; +@@ -953,14 +962,22 @@ main (int argc, char **argv) + if (selected_linker == USE_DEFAULT_LD) + selected_linker = USE_PLUGIN_LD; + } ++#if !defined (OBJECT_FORMAT_MACHO) + else if (strcmp (argv[i], "-fuse-ld=bfd") == 0) + selected_linker = USE_BFD_LD; + else if (strcmp (argv[i], "-fuse-ld=gold") == 0) + selected_linker = USE_GOLD_LD; ++#endif + else if (strcmp (argv[i], "-fuse-ld=lld") == 0) + selected_linker = USE_LLD_LD; + else if (strcmp (argv[i], "-fuse-ld=mold") == 0) + selected_linker = USE_MOLD_LD; ++#if defined (OBJECT_FORMAT_MACHO) ++ else if (strcmp (argv[i], "-fuse-ld=classic") == 0) ++ selected_linker = USE_CLASSIC_LD; ++#endif ++ else if (strcmp (argv[i], "-fuse-ld=") == 0) ++ selected_linker = USE_DEFAULT_LD; + else if (startswith (argv[i], "-o")) + { + /* Parse the output filename if it's given so that we can make +@@ -1052,7 +1069,8 @@ main (int argc, char **argv) + ld_file_name = 0; + #ifdef DEFAULT_LINKER + if (selected_linker == USE_BFD_LD || selected_linker == USE_GOLD_LD || +- selected_linker == USE_LLD_LD || selected_linker == USE_MOLD_LD) ++ selected_linker == USE_LLD_LD || selected_linker == USE_MOLD_LD || ++ selected_linker == USE_CLASSIC_LD) + { + char *linker_name; + # ifdef HOST_EXECUTABLE_SUFFIX +@@ -2266,7 +2284,7 @@ write_aix_file (FILE *stream, struct id *list) + } + #endif + +-#ifdef OBJECT_FORMAT_NONE ++#if defined (OBJECT_FORMAT_NONE) || defined (OBJECT_FORMAT_MACHO) + + /* Check to make sure the file is an LTO object file. */ -@@ -2794,6 +2798,10 @@ fstack-usage +diff --git a/gcc/common.opt b/gcc/common.opt +index b055c7bd9ac..cf32af4bbaf 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -2794,6 +2794,10 @@ fstack-usage Common RejectNegative Var(flag_stack_usage) Output stack usage information on a per-function basis. @@ -1032,47 +1749,119 @@ index 862c474d3c8..1277203d550 100644 fstrength-reduce Common Ignore Does nothing. Preserved for backward compatibility. -@@ -2862,7 +2870,7 @@ Common Var(flag_tracer) Optimization +@@ -2862,10 +2866,25 @@ Common Var(flag_tracer) Optimization Perform superblock formation via tail duplication. ftrampolines -Common Var(flag_trampolines) Init(0) -+Common Var(flag_trampolines) Init(OFF_STACK_TRAMPOLINES_INIT) ++Common Var(flag_trampolines) Init(HEAP_TRAMPOLINES_INIT) For targets that normally need trampolines for nested functions, always generate them instead of using descriptors. ++ftrampoline-impl= ++Common Joined RejectNegative Enum(trampoline_impl) Var(flag_trampoline_impl) Init(HEAP_TRAMPOLINES_INIT ? TRAMPOLINE_IMPL_HEAP : TRAMPOLINE_IMPL_STACK) ++Whether trampolines are generated in executable memory rather than ++executable stack. ++ ++Enum ++Name(trampoline_impl) Type(enum trampoline_impl) UnknownError(unknown trampoline implementation %qs) ++ ++EnumValue ++Enum(trampoline_impl) String(stack) Value(TRAMPOLINE_IMPL_STACK) ++ ++EnumValue ++Enum(trampoline_impl) String(heap) Value(TRAMPOLINE_IMPL_HEAP) ++ ++ + ; Zero means that floating-point math operations cannot generate a + ; (user-visible) trap. This is the case, for example, in nonstop + ; IEEE 754 arithmetic. +@@ -3123,6 +3142,10 @@ fuse-ld=mold + Common Driver Negative(fuse-ld=mold) + Use the Modern linker (MOLD) linker instead of the default linker. + ++fuse-ld=classic ++Common Driver Negative(fuse-ld=classic) ++Use the ld-classic linker instead of the default linker. ++ + fuse-linker-plugin + Common Undocumented Var(flag_use_linker_plugin) + +diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc +index 20bc4e1291b..5058d2feaf4 100644 +--- a/gcc/common/config/aarch64/aarch64-common.cc ++++ b/gcc/common/config/aarch64/aarch64-common.cc +@@ -301,8 +301,12 @@ aarch64_get_extension_string_for_isa_flags + + However, assemblers with Armv8-R AArch64 support should not have this + issue, so we don't need this fix when targeting Armv8-R. */ +- auto explicit_flags = (!(current_flags & AARCH64_FL_V8R) +- ? AARCH64_FL_CRC : 0); ++ aarch64_feature_flags explicit_flags = ++#ifndef DISABLE_AARCH64_AS_CRC_BUGFIX ++ (!(current_flags & AARCH64_ISA_V8R) ? AARCH64_FL_CRC : 0); ++#else ++ 0; ++#endif + + /* Add the features in isa_flags & ~current_flags using the smallest + possible number of extensions. We can do this by iterating over the +@@ -331,7 +335,10 @@ aarch64_get_extension_string_for_isa_flags + if (added & opt.flag_canonical) + { + outstr += "+"; +- outstr += opt.name; ++ if (startswith (opt.name, "rdm")) ++ outstr += "rdm"; ++ else ++ outstr += opt.name; + } + + /* Remove the features in current_flags & ~isa_flags. If the feature does +@@ -344,7 +351,10 @@ aarch64_get_extension_string_for_isa_flags + { + current_flags &= ~opt.flags_off; + outstr += "+no"; +- outstr += opt.name; ++ if (startswith (opt.name, "rdm")) ++ outstr += "rdm"; ++ else ++ outstr += opt.name; + } + + return outstr; diff --git a/gcc/config.gcc b/gcc/config.gcc -index 648b3dc2110..bac8b7c55b0 100644 +index c3b73d05eb7..1b807618a1e 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1125,6 +1125,26 @@ case ${target} in ;; esac -+# Defaults that need fixing. -+# Figure out if we need to enable -foff-stack-trampolines by default ++# Figure out if we need to enable heap trampolines ++# and variadic functions handling. +case ${target} in +aarch64*-*-darwin2*) -+ # This only applies to arm64 Darwin variadic funtions. ++ # This applies to arm64 Darwin variadic funtions. + tm_defines="$tm_defines STACK_USE_CUMULATIVE_ARGS_INIT=1" -+ # This is required; executable stack is forbidden. -+ tm_defines="$tm_defines OFF_STACK_TRAMPOLINES_INIT=1" ++ # Executable stack is forbidden. ++ tm_defines="$tm_defines HEAP_TRAMPOLINES_INIT=1" + ;; +*-*-darwin2*) + tm_defines="$tm_defines STACK_USE_CUMULATIVE_ARGS_INIT=0" + # Currently, we do this for macOS 11 and above. -+ tm_defines="$tm_defines OFF_STACK_TRAMPOLINES_INIT=1" ++ tm_defines="$tm_defines HEAP_TRAMPOLINES_INIT=1" + ;; +*) + tm_defines="$tm_defines STACK_USE_CUMULATIVE_ARGS_INIT=0" -+ tm_defines="$tm_defines OFF_STACK_TRAMPOLINES_INIT=0" ++ tm_defines="$tm_defines HEAP_TRAMPOLINES_INIT=0" + ;; +esac + case ${target} in aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*) tm_file="${tm_file} elfos.h newlib-stdint.h" -@@ -1163,6 +1183,11 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*) +@@ -1164,6 +1184,14 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*) done TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'` ;; @@ -1080,12 +1869,48 @@ index 648b3dc2110..bac8b7c55b0 100644 + tm_file="${tm_file} aarch64/aarch64-errata.h" + tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-darwin" + tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1" ++ tm_defines="${tm_defines} DISABLE_AARCH64_AS_CRC_BUGFIX=1" ++ # Choose a default CPU version that will work for all current releases. ++ with_cpu=${with_cpu:-apple-m1} + ;; aarch64*-*-freebsd*) tm_file="${tm_file} elfos.h ${fbsd_tm_file}" tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-freebsd.h" +@@ -4125,8 +4153,8 @@ case "${target}" in + fi + for which in cpu arch tune; do + eval "val=\$with_$which" +- base_val=`echo $val | sed -e 's/\+.*//'` +- ext_val=`echo $val | sed -e 's/[a-z0-9.-]\+//'` ++ base_val=`echo $val | sed -E -e 's/\+.*//'` ++ ext_val=`echo $val | sed -E -e 's/[a-z0-9.-]+//'` + + if [ $which = arch ]; then + def=aarch64-arches.def +@@ -4158,9 +4186,9 @@ case "${target}" in + + while [ x"$ext_val" != x ] + do +- ext_val=`echo $ext_val | sed -e 's/\+//'` +- ext=`echo $ext_val | sed -e 's/\+.*//'` +- base_ext=`echo $ext | sed -e 's/^no//'` ++ ext_val=`echo $ext_val | sed -E -e 's/\+//'` ++ ext=`echo $ext_val | sed -E -e 's/\+.*//'` ++ base_ext=`echo $ext | sed -E -e 's/^no//'` + opt_line=`echo -e "$options_parsed" | \ + grep "^\"$base_ext\""` + +@@ -4171,7 +4199,7 @@ case "${target}" in + echo "Unknown extension used in --with-$which=$val" 1>&2 + exit 1 + fi +- ext_val=`echo $ext_val | sed -e 's/[a-z0-9]\+//'` ++ ext_val=`echo $ext_val | sed -E -e 's/[a-z0-9]+//'` + done + + true diff --git a/gcc/config.in b/gcc/config.in -index 4cad077bfbe..428ca236a52 100644 +index 5281a12a707..b70b0bebda9 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -49,6 +49,19 @@ @@ -1108,22 +1933,43 @@ index 4cad077bfbe..428ca236a52 100644 /* Define to enable the use of a default assembler. */ #ifndef USED_FOR_TARGET #undef DEFAULT_ASSEMBLER +@@ -634,8 +647,7 @@ + #endif + + +-/* Define if your Mac OS X assembler supports -mllvm -x86-pad-for-align=false. +- */ ++/* Define if your macOS assembler supports -mllvm -x86-pad-for-align=false. */ + #ifndef USED_FOR_TARGET + #undef HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN + #endif +@@ -2201,6 +2213,12 @@ + #endif + + ++/* Define to 1 if ld64 supports '-demangle'. */ ++#ifndef USED_FOR_TARGET ++#undef LD64_HAS_DEMANGLE ++#endif ++ ++ + /* Define to 1 if ld64 supports '-export_dynamic'. */ + #ifndef USED_FOR_TARGET + #undef LD64_HAS_EXPORT_DYNAMIC diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc -index dd9f1150165..d73da323037 100644 +index 8ad82841a4d..567fb10b7fb 100644 --- a/gcc/config/aarch64/aarch64-builtins.cc +++ b/gcc/config/aarch64/aarch64-builtins.cc -@@ -785,6 +785,10 @@ enum aarch64_builtins +@@ -785,6 +785,8 @@ enum aarch64_builtins AARCH64_RBIT, AARCH64_RBITL, AARCH64_RBITLL, + /* OS-specific */ + AARCH64_BUILTIN_CFSTRING, -+ AARCH64_BUILTIN_HUGE_VALQ, -+ AARCH64_BUILTIN_INFQ, AARCH64_BUILTIN_MAX }; -@@ -920,6 +924,9 @@ tree aarch64_fp16_ptr_type_node = NULL_TREE; +@@ -920,6 +922,9 @@ tree aarch64_fp16_ptr_type_node = NULL_TREE; /* Back-end node type for brain float (bfloat) types. */ tree aarch64_bf16_ptr_type_node = NULL_TREE; @@ -1133,7 +1979,7 @@ index dd9f1150165..d73da323037 100644 /* Wrapper around add_builtin_function. NAME is the name of the built-in function, TYPE is the function type, CODE is the function subcode (relative to AARCH64_BUILTIN_GENERAL), and ATTRS is the function -@@ -1695,6 +1702,40 @@ aarch64_init_bf16_types (void) +@@ -1695,6 +1700,29 @@ aarch64_init_bf16_types (void) aarch64_bf16_ptr_type_node = build_pointer_type (bfloat16_type_node); } @@ -1142,39 +1988,28 @@ index dd9f1150165..d73da323037 100644 +static void +aarch64_init_float128_types (void) +{ -+ tree ftype, fndecl; -+ -+ /* Populate the float128 node if it is not already done so that the FEs -+ know it is available. */ -+ if (float128_type_node == NULL_TREE) ++ /* The __float128 type. The node has already been created as ++ _Float128, so for C we only need to register the __float128 name for ++ it. For C++, we create a distinct type which will mangle differently ++ (g) vs. _Float128 (DF128_) and behave backwards compatibly. */ ++ if (float128t_type_node == NULL_TREE) + { -+ float128_type_node = make_node (REAL_TYPE); -+ TYPE_PRECISION (float128_type_node) = 128; -+ SET_TYPE_MODE (float128_type_node, TFmode); -+ layout_type (float128_type_node); ++ float128t_type_node = make_node (REAL_TYPE); ++ TYPE_PRECISION (float128t_type_node) ++ = TYPE_PRECISION (float128_type_node); ++ SET_TYPE_MODE (float128t_type_node, TYPE_MODE (float128_type_node)); ++ layout_type (float128t_type_node); + } ++ lang_hooks.types.register_builtin_type (float128t_type_node, "__float128"); + -+ lang_hooks.types.register_builtin_type (float128_type_node, "__float128"); -+ aarch64_float128_ptr_type_node = build_pointer_type (float128_type_node); -+ -+ ftype = build_function_type_list (float128_type_node, NULL_TREE); -+ -+ fndecl = aarch64_general_add_builtin ("__builtin_huge_valq", ftype, -+ AARCH64_BUILTIN_HUGE_VALQ); -+ TREE_READONLY (fndecl) = 1; -+ aarch64_builtin_decls[AARCH64_BUILTIN_HUGE_VALQ] = fndecl; -+ -+ fndecl = aarch64_general_add_builtin ("__builtin_infq", ftype, -+ AARCH64_BUILTIN_INFQ); -+ TREE_READONLY (fndecl) = 1; -+ aarch64_builtin_decls[AARCH64_BUILTIN_INFQ] = fndecl; ++ aarch64_float128_ptr_type_node = build_pointer_type (float128t_type_node); +} + + /* Pointer authentication builtins that will become NOP on legacy platform. Currently, these builtins are for internal use only (libgcc EH unwinder). */ -@@ -1983,8 +2024,9 @@ aarch64_general_init_builtins (void) +@@ -1983,8 +2011,9 @@ aarch64_general_init_builtins (void) aarch64_init_fpsr_fpcr_builtins (); aarch64_init_fp16_types (); @@ -1185,7 +2020,7 @@ index dd9f1150165..d73da323037 100644 { aarch64_simd_switcher simd; -@@ -2021,6 +2063,14 @@ aarch64_general_init_builtins (void) +@@ -2021,6 +2050,14 @@ aarch64_general_init_builtins (void) handle_arm_acle_h (); } @@ -1200,27 +2035,28 @@ index dd9f1150165..d73da323037 100644 /* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group. */ tree aarch64_general_builtin_decl (unsigned code, bool) -@@ -2912,6 +2962,15 @@ aarch64_general_fold_builtin (unsigned int fcode, tree type, - if (aarch64_fold_builtin_lane_check (args[0], args[1], args[2])) - return void_node; - break; -+ case AARCH64_BUILTIN_HUGE_VALQ: -+ case AARCH64_BUILTIN_INFQ: -+ { -+ gcc_assert (n_args == 0); -+ REAL_VALUE_TYPE inf; -+ real_inf (&inf); -+ return build_real (type, inf); -+ } -+ break; - default: - break; - } diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc -index 578ec6f45b0..1601887c86f 100644 +index 578ec6f45b0..56c83ac05a7 100644 --- a/gcc/config/aarch64/aarch64-c.cc +++ b/gcc/config/aarch64/aarch64-c.cc -@@ -359,4 +359,8 @@ aarch64_register_pragmas (void) +@@ -224,6 +224,16 @@ aarch64_cpu_cpp_builtins (cpp_reader *pfile) + { + aarch64_define_unconditional_macros (pfile); + aarch64_update_cpp_builtins (pfile); ++ ++ if (TARGET_MACHO) ++ { ++ builtin_define ("__builtin_copysignq=__builtin_copysignf128"); ++ builtin_define ("__builtin_fabsq=__builtin_fabsf128"); ++ builtin_define ("__builtin_huge_valq=__builtin_huge_valf128"); ++ builtin_define ("__builtin_infq=__builtin_inff128"); ++ builtin_define ("__builtin_nanq=__builtin_nanf128"); ++ builtin_define ("__builtin_nansq=__builtin_nansf128"); ++ } + } + + /* Hook to validate the current #pragma GCC target and set the state, and +@@ -359,4 +369,8 @@ aarch64_register_pragmas (void) targetm.check_builtin_call = aarch64_check_builtin_call; c_register_pragma ("GCC", "aarch64", aarch64_pragma_aarch64); @@ -1229,8 +2065,31 @@ index 578ec6f45b0..1601887c86f 100644 + REGISTER_SUBTARGET_PRAGMAS (); +#endif } +diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def +index fdda0697b88..2dc4ae6ce52 100644 +--- a/gcc/config/aarch64/aarch64-cores.def ++++ b/gcc/config/aarch64/aarch64-cores.def +@@ -165,6 +165,18 @@ AARCH64_CORE("cortex-a76.cortex-a55", cortexa76cortexa55, cortexa53, V8_2A, (F + /* Armv8-R Architecture Processors. */ + AARCH64_CORE("cortex-r82", cortexr82, cortexa53, V8R, (), cortexa53, 0x41, 0xd15, -1) + ++/* Apple (A12 and M) cores. ++ Apple implementer ID from xnu, ++ guesses for part #, guesses for scheduler ident, generic_armv8_a for costs. ++ A12 seems mostly 8.3, ++ M1 seems to be 8.4 + extras (see comments in option-extensions about f16fml), ++ M2 mostly 8.5 but with missing mandatory features. ++ M3 is pretty much the same as M2. */ ++AARCH64_CORE("apple-a12", applea12, cortexa53, V8_3A, (), cortexa53, 0x61, 0x12, -1) ++AARCH64_CORE("apple-m1", applem1, cortexa57, V8_4A, (F16, SB, SSBS), cortexa73, 0x61, 0x23, -1) ++AARCH64_CORE("apple-m2", applem2, cortexa57, V8_4A, (I8MM, BF16, F16, SB, SSBS), cortexa73, 0x61, 0x23, -1) ++AARCH64_CORE("apple-m3", applem3, cortexa57, V8_4A, (I8MM, BF16, F16, SB, SSBS), cortexa73, 0x61, 0x23, -1) ++ + /* Armv9.0-A Architecture Processors. */ + + /* Arm ('A') cores. */ diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h -index e727e207367..e6a4be70752 100644 +index 32716f6cb15..a107f9ef069 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -109,6 +109,14 @@ enum aarch64_symbol_type @@ -1256,15 +2115,19 @@ index e727e207367..e6a4be70752 100644 bool aarch64_bitmask_imm (unsigned HOST_WIDE_INT val, machine_mode); unsigned HOST_WIDE_INT aarch64_and_split_imm1 (HOST_WIDE_INT val_in); unsigned HOST_WIDE_INT aarch64_and_split_imm2 (HOST_WIDE_INT val_in); -@@ -898,6 +907,7 @@ void aarch64_expand_vector_init (rtx, rtx); - void aarch64_sve_expand_vector_init (rtx, rtx); - void aarch64_init_cumulative_args (CUMULATIVE_ARGS *, const_tree, rtx, - const_tree, unsigned, bool = false); -+void aarch64_init_cumulative_incoming_args (CUMULATIVE_ARGS *, const_tree, rtx); - void aarch64_init_expanders (void); - void aarch64_emit_call_insn (rtx); - void aarch64_register_pragmas (void); -@@ -970,6 +980,7 @@ void aarch64_override_options_internal (struct gcc_options *); +@@ -775,7 +784,11 @@ bool aarch64_is_extend_from_extract (scalar_int_mode, rtx, rtx); + bool aarch64_is_long_call_p (rtx); + bool aarch64_is_noplt_call_p (rtx); + bool aarch64_label_mentioned_p (rtx); ++#if TARGET_MACHO ++void aarch64_darwin_declare_function_name (FILE *, const char*, tree ); ++#else + void aarch64_declare_function_name (FILE *, const char*, tree); ++#endif + void aarch64_asm_output_alias (FILE *, const tree, const tree); + void aarch64_asm_output_external (FILE *, tree, const char*); + bool aarch64_legitimate_pic_operand_p (rtx); +@@ -971,6 +984,7 @@ void aarch64_override_options_internal (struct gcc_options *); const char *aarch64_general_mangle_builtin_type (const_tree); void aarch64_general_init_builtins (void); @@ -1272,8 +2135,19 @@ index e727e207367..e6a4be70752 100644 tree aarch64_general_fold_builtin (unsigned int, tree, unsigned int, tree *); gimple *aarch64_general_gimple_fold_builtin (unsigned int, gcall *, gimple_stmt_iterator *); +diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md +index 9d46d38a292..3c3aa72d3de 100644 +--- a/gcc/config/aarch64/aarch64-tune.md ++++ b/gcc/config/aarch64/aarch64-tune.md +@@ -1,5 +1,5 @@ + ;; -*- buffer-read-only: t -*- + ;; Generated automatically by gentune.sh from aarch64-cores.def + (define_attr "tune" +- "cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa78,cortexa78ae,cortexa78c,cortexa65,cortexa65ae,cortexx1,cortexx1c,neoversen1,ares,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,neoversev1,zeus,neoverse512tvb,saphira,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55,cortexr82,cortexa510,cortexa710,cortexa715,cortexx2,cortexx3,neoversen2,cobalt100,neoversev2,demeter" ++ "cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa78,cortexa78ae,cortexa78c,cortexa65,cortexa65ae,cortexx1,cortexx1c,neoversen1,ares,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,neoversev1,zeus,neoverse512tvb,saphira,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55,cortexr82,applea12,applem1,applem2,applem3,cortexa510,cortexa710,cortexa715,cortexx2,cortexx3,neoversen2,cobalt100,neoversev2,demeter" + (const (symbol_ref "((enum attr_tune) aarch64_tune)"))) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc -index f5db5379543..25443d35141 100644 +index b8a4ab1b980..d2f503447ae 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -295,8 +295,10 @@ static bool aarch64_vfp_is_call_or_return_candidate (machine_mode, @@ -1287,16 +2161,16 @@ index f5db5379543..25443d35141 100644 static void aarch64_override_options_after_change (void); static bool aarch64_vector_mode_supported_p (machine_mode); static int aarch64_address_cost (rtx, machine_mode, addr_space_t, bool); -@@ -2803,6 +2805,9 @@ static const struct attribute_spec aarch64_attribute_table[] = - { "Advanced SIMD type", 1, 1, false, true, false, true, NULL, NULL }, - { "SVE type", 3, 3, false, true, false, true, NULL, NULL }, - { "SVE sizeless type", 0, 0, false, true, false, true, NULL, NULL }, +@@ -2795,6 +2797,9 @@ static const struct attribute_spec aarch64_attribute_table[] = + { + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, + affects_type_identity, handler, exclude } */ +#ifdef SUBTARGET_ATTRIBUTE_TABLE + SUBTARGET_ATTRIBUTE_TABLE, +#endif - { NULL, 0, 0, false, false, false, false, NULL, NULL } - }; - + { "aarch64_vector_pcs", 0, 0, false, true, true, true, + handle_aarch64_vector_pcs_attribute, NULL }, + { "arm_sve_vector_bits", 1, 1, false, true, false, true, @@ -3949,7 +3954,7 @@ aarch64_hard_regno_mode_ok (unsigned regno, machine_mode mode) if (known_le (GET_MODE_SIZE (mode), 8)) return true; @@ -1388,6 +2262,15 @@ index f5db5379543..25443d35141 100644 /* Given MODE and TYPE of a function argument, return the alignment in bits. The idea is to suppress any stronger alignment requested by +@@ -7481,7 +7509,7 @@ aarch64_function_arg_alignment (machine_mode mode, const_tree type, + if (integer_zerop (TYPE_SIZE (type))) + return 0; + +- gcc_assert (TYPE_MODE (type) == mode); ++ gcc_assert (TARGET_MACHO || TYPE_MODE (type) == mode); + + if (!AGGREGATE_TYPE_P (type)) + { @@ -7641,6 +7669,14 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg) Both behaviors were wrong, but in different cases. */ @@ -1492,18 +2375,12 @@ index f5db5379543..25443d35141 100644 return; } -@@ -7853,7 +7922,6 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg) +@@ -7853,7 +7922,81 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg) /* The argument is passed on stack; record the needed number of words for this argument and align the total size if necessary. */ on_stack: - pcum->aapcs_stack_words = size / UNITS_PER_WORD; - - if (warn_pcs_change - && abi_break_packed -@@ -7862,6 +7930,83 @@ on_stack: - inform (input_location, "parameter passing for argument of type " - "%qT changed in GCC 13.1", type); - ++ + if (TARGET_MACHO) + { + /* Darwin does not round up the allocation for smaller entities to 8 @@ -1522,7 +2399,7 @@ index f5db5379543..25443d35141 100644 + change nor the warning should fire here (i.e. we do not need to check + if 16byte entities alter the stack size). */ + -+gcc_checking_assert (arg.named == pcum->named_p); ++ gcc_checking_assert (arg.named == pcum->named_p); + pcum->darwinpcs_arg_padding = BITS_PER_UNIT; + if (!pcum->named_p + || TREE_CODE (type) == COMPLEX_TYPE @@ -1578,7 +2455,13 @@ index f5db5379543..25443d35141 100644 + } + return; + } -+ + + if (warn_pcs_change + && abi_break_packed +@@ -7862,6 +8005,8 @@ on_stack: + inform (input_location, "parameter passing for argument of type " + "%qT changed in GCC 13.1", type); + + /* size was already rounded up to PARM_BOUNDARY. */ + pcum->aapcs_stack_words = size / UNITS_PER_WORD; if (alignment == 16 * BITS_PER_UNIT) @@ -1769,7 +2652,7 @@ index f5db5379543..25443d35141 100644 } /* Implement TARGET_GET_RAW_RESULT_MODE and TARGET_GET_RAW_ARG_MODE. */ -@@ -11030,6 +11306,7 @@ aarch64_classify_address (struct aarch64_address_info *info, +@@ -11091,6 +11367,7 @@ aarch64_classify_address (struct aarch64_address_info *info, /* load literal: pc-relative constant pool entry. Only supported for SI mode or larger. */ info->type = ADDRESS_SYMBOLIC; @@ -1777,7 +2660,7 @@ index f5db5379543..25443d35141 100644 if (!load_store_pair_p && GET_MODE_SIZE (mode).is_constant (&const_size) -@@ -11037,6 +11314,7 @@ aarch64_classify_address (struct aarch64_address_info *info, +@@ -11098,6 +11375,7 @@ aarch64_classify_address (struct aarch64_address_info *info, { poly_int64 offset; rtx sym = strip_offset_and_salt (x, &offset); @@ -1785,7 +2668,7 @@ index f5db5379543..25443d35141 100644 return ((LABEL_REF_P (sym) || (SYMBOL_REF_P (sym) && CONSTANT_POOL_ADDRESS_P (sym) -@@ -11054,10 +11332,13 @@ aarch64_classify_address (struct aarch64_address_info *info, +@@ -11115,10 +11393,13 @@ aarch64_classify_address (struct aarch64_address_info *info, poly_int64 offset; HOST_WIDE_INT const_offset; rtx sym = strip_offset_and_salt (info->offset, &offset); @@ -1800,7 +2683,7 @@ index f5db5379543..25443d35141 100644 { /* The symbol and offset must be aligned to the access size. */ unsigned int align; -@@ -11107,6 +11388,55 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p) +@@ -11168,6 +11449,55 @@ aarch64_address_valid_for_prefetch_p (rtx x, bool strict_p) if (!res) return false; @@ -1856,7 +2739,7 @@ index f5db5379543..25443d35141 100644 /* ... except writeback forms. */ return addr.type != ADDRESS_REG_WB; } -@@ -11820,6 +12150,144 @@ sizetochar (int size) +@@ -11881,6 +12211,144 @@ sizetochar (int size) } } @@ -2001,11 +2884,11 @@ index f5db5379543..25443d35141 100644 /* Print operand X to file F in a target specific manner according to CODE. The acceptable formatting commands given by CODE are: 'c': An integer or symbol address without a preceding # -@@ -11888,6 +12356,12 @@ aarch64_print_operand (FILE *f, rtx x, int code) +@@ -11949,6 +12417,12 @@ aarch64_print_operand (FILE *f, rtx x, int code) } break; -+ case 'K': ++ case 'J': + output_macho_postfix_expr (f, x, "PAGEOFF"); + break; + case 'O': @@ -2014,7 +2897,7 @@ index f5db5379543..25443d35141 100644 case 'e': { x = unwrap_const_vec_duplicate (x); -@@ -12211,7 +12685,7 @@ aarch64_print_operand (FILE *f, rtx x, int code) +@@ -12272,7 +12746,7 @@ aarch64_print_operand (FILE *f, rtx x, int code) case 'A': if (GET_CODE (x) == HIGH) x = XEXP (x, 0); @@ -2023,26 +2906,23 @@ index f5db5379543..25443d35141 100644 switch (aarch64_classify_symbolic_expression (x)) { case SYMBOL_SMALL_GOT_4G: -@@ -12242,9 +12716,29 @@ aarch64_print_operand (FILE *f, rtx x, int code) +@@ -12303,9 +12777,26 @@ aarch64_print_operand (FILE *f, rtx x, int code) break; } output_addr_const (asm_out_file, x); +#endif +#if TARGET_MACHO -+ // FIXME update classify symbolic expression to handle macho. + switch (aarch64_classify_symbolic_expression (x)) + { + case SYMBOL_MO_SMALL_PCR: + output_macho_postfix_expr (asm_out_file, x, "PAGE"); -+// asm_fprintf (asm_out_file, "@PAGE;mopcr"); + break; + case SYMBOL_MO_SMALL_GOT: + output_macho_postfix_expr (asm_out_file, x, "GOTPAGE"); -+// asm_fprintf (asm_out_file, "@GOTPAGE;mosg"); + break; + default: -+ output_macho_postfix_expr (asm_out_file, x, "BLEAH"); -+// asm_fprintf (asm_out_file, "@BLEAH"); ++ /* large code model unimplemented. */ ++ gcc_unreachable (); + break; + } +#endif @@ -2053,7 +2933,7 @@ index f5db5379543..25443d35141 100644 switch (aarch64_classify_symbolic_expression (x)) { case SYMBOL_SMALL_GOT_4G: -@@ -12282,10 +12776,12 @@ aarch64_print_operand (FILE *f, rtx x, int code) +@@ -12343,10 +12834,12 @@ aarch64_print_operand (FILE *f, rtx x, int code) default: break; } @@ -2066,7 +2946,7 @@ index f5db5379543..25443d35141 100644 switch (aarch64_classify_symbolic_expression (x)) { case SYMBOL_TLSLE24: -@@ -12294,6 +12790,7 @@ aarch64_print_operand (FILE *f, rtx x, int code) +@@ -12355,6 +12848,7 @@ aarch64_print_operand (FILE *f, rtx x, int code) default: break; } @@ -2074,14 +2954,13 @@ index f5db5379543..25443d35141 100644 output_addr_const (asm_out_file, x); break; -@@ -12443,8 +12940,14 @@ aarch64_print_address_internal (FILE *f, machine_mode mode, rtx x, +@@ -12504,8 +12998,13 @@ aarch64_print_address_internal (FILE *f, machine_mode mode, rtx x, break; case ADDRESS_LO_SUM: +#if TARGET_MACHO + asm_fprintf (f, "[%s, #", reg_names [REGNO (addr.base)]); + output_macho_postfix_expr (f, addr.offset, "PAGEOFF"); -+// output_addr_const (f, addr.offset); +#else asm_fprintf (f, "[%s, #:lo12:", reg_names [REGNO (addr.base)]); output_addr_const (f, addr.offset); @@ -2089,28 +2968,55 @@ index f5db5379543..25443d35141 100644 asm_fprintf (f, "]"); return true; -@@ -12942,6 +13445,8 @@ aarch64_asm_output_labelref (FILE* f, const char *name) - asm_fprintf (f, "%U%s", name); +@@ -12786,6 +13285,26 @@ aarch64_secondary_memory_needed (machine_mode mode, reg_class_t class1, + return false; } -+#if !TARGET_MACHO ++#if TARGET_MACHO ++/* Implement TARGET_FRAME_POINTER_REQUIRED. */ + - static void - aarch64_elf_asm_constructor (rtx symbol, int priority) - { -@@ -12981,6 +13486,7 @@ aarch64_elf_asm_destructor (rtx symbol, int priority) - assemble_aligned_integer (POINTER_BYTES, symbol); - } - } -+#endif ++static bool ++aarch64_darwin_frame_pointer_required () ++{ ++ if (crtl->calls_eh_return) ++ return true; ++ ++ /* Not used in leaf functions (unless forced). */ ++ if (flag_omit_leaf_frame_pointer && leaf_function_p ()) ++ return false; ++ ++ /* NOTE: We are allowing the user to force omission of the frame ++ pointer, (despite that it is not ABI-compliant). */ ++ ++ return flag_omit_frame_pointer != 1; ++} ++#endif ++ + static bool + aarch64_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to) + { +@@ -13003,6 +13522,8 @@ aarch64_asm_output_labelref (FILE* f, const char *name) + asm_fprintf (f, "%U%s", name); + } + ++#if !TARGET_MACHO ++ + static void + aarch64_elf_asm_constructor (rtx symbol, int priority) + { +@@ -13042,6 +13563,7 @@ aarch64_elf_asm_destructor (rtx symbol, int priority) + assemble_aligned_integer (POINTER_BYTES, symbol); + } + } ++#endif const char* aarch64_output_casesi (rtx *operands) -@@ -13084,7 +13590,11 @@ aarch64_select_rtx_section (machine_mode mode, +@@ -13145,7 +13667,11 @@ aarch64_select_rtx_section (machine_mode mode, if (aarch64_can_use_per_function_literal_pools_p ()) return function_section (current_function_decl); -+#ifdef TARGET_MACHO ++#if TARGET_MACHO + return machopic_select_rtx_section (mode, x, align); +#else return default_elf_select_rtx_section (mode, x, align); @@ -2118,7 +3024,7 @@ index f5db5379543..25443d35141 100644 } /* Implement ASM_OUTPUT_POOL_EPILOGUE. */ -@@ -15308,15 +15818,17 @@ aarch64_init_builtins () +@@ -15369,15 +15895,17 @@ aarch64_init_builtins () { aarch64_general_init_builtins (); aarch64_sve::init_builtins (); @@ -2139,7 +3045,7 @@ index f5db5379543..25443d35141 100644 unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); unsigned int subcode = code >> AARCH64_BUILTIN_SHIFT; tree type = TREE_TYPE (TREE_TYPE (fndecl)); -@@ -18500,10 +19012,14 @@ initialize_aarch64_code_model (struct gcc_options *opts) +@@ -18561,10 +19089,14 @@ initialize_aarch64_code_model (struct gcc_options *opts) } break; case AARCH64_CMODEL_LARGE: @@ -2147,7 +3053,7 @@ index f5db5379543..25443d35141 100644 + if (TARGET_MACHO) + /* We need to implement fPIC here (arm64_32 also accepts the large + model). */ -+ ; ++ sorry ("code model %qs not supported yet", "large"); + else if (opts->x_flag_pic) sorry ("code model %qs with %<-f%s%>", "large", opts->x_flag_pic > 1 ? "PIC" : "pic"); @@ -2156,7 +3062,7 @@ index f5db5379543..25443d35141 100644 sorry ("code model %qs not supported in ilp32 mode", "large"); break; case AARCH64_CMODEL_TINY_PIC: -@@ -19389,7 +19905,9 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) +@@ -19450,7 +19982,9 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) case AARCH64_CMODEL_SMALL_SPIC: case AARCH64_CMODEL_SMALL_PIC: case AARCH64_CMODEL_SMALL: @@ -2167,7 +3073,7 @@ index f5db5379543..25443d35141 100644 default: gcc_unreachable (); -@@ -19425,10 +19943,22 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) +@@ -19486,10 +20020,22 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) return SYMBOL_TINY_ABSOLUTE; @@ -2191,7 +3097,7 @@ index f5db5379543..25443d35141 100644 if ((flag_pic || SYMBOL_REF_WEAK (x)) && !aarch64_symbol_binds_local_p (x)) return aarch64_cmodel == AARCH64_CMODEL_SMALL_SPIC -@@ -19440,7 +19970,8 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) +@@ -19501,7 +20047,8 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset) || offset_within_block_p (x, offset))) return SYMBOL_FORCE_TO_MEM; @@ -2201,7 +3107,7 @@ index f5db5379543..25443d35141 100644 case AARCH64_CMODEL_LARGE: /* This is alright even in PIC code as the constant -@@ -19570,7 +20101,10 @@ static GTY(()) tree va_list_type; +@@ -19631,7 +20178,10 @@ static GTY(()) tree va_list_type; void *__vr_top; int __gr_offs; int __vr_offs; @@ -2213,7 +3119,7 @@ index f5db5379543..25443d35141 100644 static tree aarch64_build_builtin_va_list (void) -@@ -19578,6 +20112,13 @@ aarch64_build_builtin_va_list (void) +@@ -19639,6 +20189,13 @@ aarch64_build_builtin_va_list (void) tree va_list_name; tree f_stack, f_grtop, f_vrtop, f_groff, f_vroff; @@ -2227,7 +3133,7 @@ index f5db5379543..25443d35141 100644 /* Create the type. */ va_list_type = lang_hooks.types.make_type (RECORD_TYPE); /* Give it the required name. */ -@@ -19649,6 +20190,13 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED) +@@ -19710,6 +20267,13 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED) int vr_save_area_size = cfun->va_list_fpr_size; int vr_offset; @@ -2241,7 +3147,7 @@ index f5db5379543..25443d35141 100644 cum = &crtl->args.info; if (cfun->va_list_gpr_size) gr_save_area_size = MIN ((NUM_ARG_REGS - cum->aapcs_ncrn) * UNITS_PER_WORD, -@@ -19739,6 +20287,9 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, +@@ -19800,6 +20364,9 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, HOST_WIDE_INT size, rsize, adjust, align; tree t, u, cond1, cond2; @@ -2251,7 +3157,7 @@ index f5db5379543..25443d35141 100644 indirect_p = pass_va_arg_by_reference (type); if (indirect_p) type = build_pointer_type (type); -@@ -19929,8 +20480,18 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, +@@ -19990,8 +20557,18 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, field_ptr_t = double_ptr_type_node; break; case E_TFmode: @@ -2272,7 +3178,7 @@ index f5db5379543..25443d35141 100644 break; case E_SDmode: field_t = dfloat32_type_node; -@@ -20013,6 +20574,9 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v, +@@ -20074,6 +20651,9 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v, int gr_saved = cfun->va_list_gpr_size; int vr_saved = cfun->va_list_fpr_size; @@ -2282,7 +3188,7 @@ index f5db5379543..25443d35141 100644 /* The caller has advanced CUM up to, but not beyond, the last named argument. Advance a local copy of CUM past the last "real" named argument, to find out how many registers are left over. */ -@@ -20845,6 +21409,12 @@ aarch64_autovectorize_vector_modes (vector_modes *modes, bool) +@@ -20906,6 +21486,12 @@ aarch64_autovectorize_vector_modes (vector_modes *modes, bool) static const char * aarch64_mangle_type (const_tree type) { @@ -2295,18 +3201,20 @@ index f5db5379543..25443d35141 100644 /* The AArch64 ABI documents say that "__va_list" has to be mangled as if it is in the "std" namespace. */ if (lang_hooks.types_compatible_p (CONST_CAST_TREE (type), va_list_type)) -@@ -20861,6 +21431,10 @@ aarch64_mangle_type (const_tree type) +@@ -20922,6 +21508,12 @@ aarch64_mangle_type (const_tree type) return "Dh"; } -+ /* __float128 */ -+ if (TYPE_MODE (type) == TFmode) ++ /* __float128 is mangled as "g" on darwin. _Float128 is not mangled here, ++ but handled in common code (as "DF128_"). */ ++ if (TARGET_MACHO && TYPE_MODE (type) == TFmode ++ && TYPE_MAIN_VARIANT (type) == float128t_type_node) + return "g"; + /* Mangle AArch64-specific internal types. TYPE_NAME is non-NULL_TREE for builtin types. */ if (TYPE_NAME (type) != NULL) -@@ -21554,7 +22128,8 @@ aarch64_mov_operand_p (rtx x, machine_mode mode) +@@ -21615,7 +22207,8 @@ aarch64_mov_operand_p (rtx x, machine_mode mode) /* GOT accesses are valid moves. */ if (SYMBOL_REF_P (x) @@ -2316,17 +3224,84 @@ index f5db5379543..25443d35141 100644 return true; if (SYMBOL_REF_P (x) && mode == DImode && CONSTANT_ADDRESS_P (x)) -@@ -22746,7 +23321,9 @@ aarch64_declare_function_name (FILE *stream, const char* name, +@@ -22759,12 +23352,8 @@ aarch64_asm_output_variant_pcs (FILE *stream, const tree decl, const char* name) + static std::string aarch64_last_printed_arch_string; + static std::string aarch64_last_printed_tune_string; + +-/* Implement ASM_DECLARE_FUNCTION_NAME. Output the ISA features used +- by the function fndecl. */ +- +-void +-aarch64_declare_function_name (FILE *stream, const char* name, +- tree fndecl) ++static void ++aarch64_function_options_preamble (tree fndecl) + { + tree target_parts = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); + +@@ -22803,15 +23392,60 @@ aarch64_declare_function_name (FILE *stream, const char* name, + this_tune->name); + aarch64_last_printed_tune_string = this_tune->name; + } ++} ++ ++/* Implement ASM_DECLARE_FUNCTION_NAME. Output the ISA features used ++ by the function fndecl. */ + ++#if TARGET_MACHO ++void ++aarch64_darwin_declare_function_name (FILE *stream, const char* name, ++ tree fndecl) ++{ ++ gcc_checking_assert (TREE_CODE (fndecl) == FUNCTION_DECL); ++ gcc_checking_assert (!DECL_COMMON (fndecl)); ++ ++ /* Update .arch and .tune as needed. */ ++ aarch64_function_options_preamble (fndecl); ++ ++ /* Darwin does not emit pcs variant info. */ ++ ++ rtx decl_rtx = XEXP (DECL_RTL (fndecl), 0); ++ if (GET_CODE (decl_rtx) != SYMBOL_REF) ++ name = IDENTIFIER_POINTER (DECL_NAME (fndecl)); ++ ++ if (! DECL_WEAK (fndecl) ++ && ((TREE_STATIC (fndecl) && !TREE_PUBLIC (fndecl)) ++ || DECL_INITIAL (fndecl))) ++ machopic_define_symbol (DECL_RTL (fndecl)); ++ if ((TREE_STATIC (fndecl) && !TREE_PUBLIC (fndecl)) ++ || DECL_INITIAL (fndecl)) ++ (* targetm.encode_section_info) (fndecl, DECL_RTL (fndecl), false); ++ ASM_OUTPUT_FUNCTION_LABEL (stream, name, fndecl); ++ ++ cfun->machine->label_is_assembled = true; ++} ++ ++#else ++ ++void ++aarch64_declare_function_name (FILE *stream, const char* name, ++ tree fndecl) ++{ ++ /* Update .arch and .tune as needed. */ ++ aarch64_function_options_preamble (fndecl); ++ /* Emit any necessary pcs information. */ aarch64_asm_output_variant_pcs (stream, fndecl, name); /* Don't forget the type directive for ELF. */ +#ifdef ASM_OUTPUT_TYPE_DIRECTIVE ASM_OUTPUT_TYPE_DIRECTIVE (stream, name, "function"); +- ASM_OUTPUT_LABEL (stream, name); +#endif - ASM_OUTPUT_LABEL (stream, name); ++ ASM_OUTPUT_FUNCTION_LABEL (stream, name, fndecl); cfun->machine->label_is_assembled = true; -@@ -22807,12 +23384,17 @@ aarch64_output_patchable_area (unsigned int patch_area_size, bool record_p) + } ++#endif + + /* Implement PRINT_PATCHABLE_FUNCTION_ENTRY. */ + +@@ -22868,12 +23502,17 @@ aarch64_output_patchable_area (unsigned int patch_area_size, bool record_p) /* Implement ASM_OUTPUT_DEF_FROM_DECLS. Output .variant_pcs for aliases. */ void @@ -2345,7 +3320,28 @@ index f5db5379543..25443d35141 100644 } /* Implement ASM_OUTPUT_EXTERNAL. Output .variant_pcs for undefined -@@ -23436,6 +24018,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width, +@@ -22919,6 +23558,9 @@ aarch64_start_file (void) + aarch64_last_printed_arch_string.c_str ()); + + default_file_start (); ++#if TARGET_MACHO ++ darwin_file_start (); ++#endif + } + + /* Emit load exclusive. */ +@@ -23396,6 +24038,10 @@ aarch64_float_const_representable_p (rtx x) + || REAL_VALUE_MINUS_ZERO (r)) + return false; + ++ /* For BFmode, only handle 0.0. */ ++ if (GET_MODE (x) == BFmode) ++ return real_iszero (&r, false); ++ + /* Extract exponent. */ + r = real_value_abs (&r); + exponent = REAL_EXP (&r); +@@ -23499,6 +24145,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width, } gcc_assert (CONST_INT_P (info.u.mov.value)); @@ -2362,7 +3358,7 @@ index f5db5379543..25443d35141 100644 if (which == AARCH64_CHECK_MOV) { -@@ -23444,16 +24036,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width, +@@ -23507,16 +24163,16 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width, ? "msl" : "lsl"); if (lane_count == 1) snprintf (templ, sizeof (templ), "%s\t%%d0, " HOST_WIDE_INT_PRINT_HEX, @@ -2382,7 +3378,7 @@ index f5db5379543..25443d35141 100644 } else { -@@ -23462,12 +24054,12 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width, +@@ -23525,12 +24181,12 @@ aarch64_output_simd_mov_immediate (rtx const_vector, unsigned width, if (info.u.mov.shift) snprintf (templ, sizeof (templ), "%s\t%%0.%d%c, #" HOST_WIDE_INT_PRINT_DEC ", %s #%d", mnemonic, lane_count, @@ -2397,7 +3393,7 @@ index f5db5379543..25443d35141 100644 } return templ; } -@@ -26664,7 +27256,8 @@ aarch64_libgcc_floating_mode_supported_p (scalar_float_mode mode) +@@ -26728,7 +27384,8 @@ aarch64_libgcc_floating_mode_supported_p (scalar_float_mode mode) } /* Implement TARGET_SCALAR_MODE_SUPPORTED_P - return TRUE @@ -2407,7 +3403,7 @@ index f5db5379543..25443d35141 100644 static bool aarch64_scalar_mode_supported_p (scalar_mode mode) -@@ -26672,7 +27265,7 @@ aarch64_scalar_mode_supported_p (scalar_mode mode) +@@ -26736,7 +27393,7 @@ aarch64_scalar_mode_supported_p (scalar_mode mode) if (DECIMAL_FLOAT_MODE_P (mode)) return default_decimal_float_supported_p (); @@ -2416,7 +3412,7 @@ index f5db5379543..25443d35141 100644 ? true : default_scalar_mode_supported_p (mode)); } -@@ -27402,19 +27995,37 @@ aarch64_sls_emit_shared_blr_thunks (FILE *out_file) +@@ -27476,19 +28133,37 @@ aarch64_sls_emit_shared_blr_thunks (FILE *out_file) continue; const char *name = indirect_symbol_names[regnum]; @@ -2457,7 +3453,68 @@ index f5db5379543..25443d35141 100644 } } -@@ -27607,6 +28218,15 @@ aarch64_run_selftests (void) +@@ -27519,6 +28194,60 @@ aarch64_indirect_call_asm (rtx addr) + return ""; + } + ++#if TARGET_MACHO ++/* This handles the promotion of function return values. ++ It also handles function args under two specific curcumstances: ++ - called from combine with a register argument ++ - caller for a libcall with type == NULL. ++ The remaining cases for argument promotion are handled with access to ++ cumulative args data, below. */ ++machine_mode ++aarch64_darwin_promote_fn_mode (const_tree type, machine_mode mode, ++ int *punsignedp, ++ const_tree funtype ATTRIBUTE_UNUSED, ++ int for_return ATTRIBUTE_UNUSED) ++{ ++ /* With the amended use of promote using cargs, the only cases that arrive ++ here with for_return == 0 are from combine (where the value is definitely ++ in a register) and for libcalls, where type == NULL. We want to promote ++ function return values in the callee, so this becomes pretty much ++ unconditional now. */ ++ if (type != NULL_TREE) ++ return promote_mode (type, mode, punsignedp); ++ return mode; ++} ++ ++/* Ensure that we only promote the mode of named parms when they are passed in ++ a register. Named values passed on the stack retain their original mode and ++ alignment. */ ++machine_mode ++aarch64_darwin_promote_function_mode_ca (cumulative_args_t ca, ++ function_arg_info arg, ++ const_tree funtype ATTRIBUTE_UNUSED, ++ int *punsignedp, ++ int for_return ATTRIBUTE_UNUSED) ++{ ++ tree type = arg.type; ++ machine_mode mode = arg.mode; ++ machine_mode new_mode = promote_mode (type, mode, punsignedp); ++ if (new_mode == mode || arg.named == false ++ || GET_MODE_CLASS (new_mode) != MODE_INT ++ || known_gt (GET_MODE_SIZE (new_mode), 4)) ++ return new_mode; ++ ++ CUMULATIVE_ARGS *pcum = get_cumulative_args (ca); ++ /* Make sure that changes in assumption do not get missed. */ ++ gcc_checking_assert (for_return == 0 && new_mode == SImode ++ && !pcum->aapcs_arg_processed); ++ /* We have a named integer value that fits in a reg; if there's one available ++ then promote the value. */ ++ if (pcum->aapcs_ncrn < 8) ++ return new_mode; ++ return mode; ++} ++ ++#endif ++ + /* Target-specific selftests. */ + + #if CHECKING_P +@@ -27681,6 +28410,15 @@ aarch64_run_selftests (void) #undef TARGET_ASM_ALIGNED_SI_OP #define TARGET_ASM_ALIGNED_SI_OP "\t.word\t" @@ -2473,7 +3530,7 @@ index f5db5379543..25443d35141 100644 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK #define TARGET_ASM_CAN_OUTPUT_MI_THUNK \ hook_bool_const_tree_hwi_hwi_const_tree_true -@@ -27693,6 +28313,12 @@ aarch64_run_selftests (void) +@@ -27767,6 +28505,12 @@ aarch64_run_selftests (void) #undef TARGET_FUNCTION_ARG_BOUNDARY #define TARGET_FUNCTION_ARG_BOUNDARY aarch64_function_arg_boundary @@ -2486,7 +3543,7 @@ index f5db5379543..25443d35141 100644 #undef TARGET_FUNCTION_ARG_PADDING #define TARGET_FUNCTION_ARG_PADDING aarch64_function_arg_padding -@@ -28017,7 +28643,7 @@ aarch64_libgcc_floating_mode_supported_p +@@ -28091,7 +28835,7 @@ aarch64_libgcc_floating_mode_supported_p /* The architecture reserves bits 0 and 1 so use bit 2 for descriptors. */ #undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS @@ -2495,8 +3552,20 @@ index f5db5379543..25443d35141 100644 #undef TARGET_HARD_REGNO_NREGS #define TARGET_HARD_REGNO_NREGS aarch64_hard_regno_nregs +@@ -28181,6 +28925,11 @@ aarch64_libgcc_floating_mode_supported_p + #undef TARGET_CONST_ANCHOR + #define TARGET_CONST_ANCHOR 0x1000000 + ++#if TARGET_MACHO ++#undef TARGET_FRAME_POINTER_REQUIRED ++#define TARGET_FRAME_POINTER_REQUIRED aarch64_darwin_frame_pointer_required ++#endif ++ + struct gcc_target targetm = TARGET_INITIALIZER; + + #include "gt-aarch64.h" diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h -index 73b09e20508..d11c0ba21b4 100644 +index cfeaf4657ab..81d5658f1cb 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -65,6 +65,10 @@ @@ -2523,7 +3592,7 @@ index 73b09e20508..d11c0ba21b4 100644 /* Defined by the ABI */ #define WCHAR_TYPE "unsigned int" #define WCHAR_TYPE_SIZE 32 -@@ -934,6 +944,24 @@ typedef struct +@@ -944,6 +954,24 @@ typedef struct aapcs_reg == NULL_RTX. */ int aapcs_stack_size; /* The total size (in words, per 8 byte) of the stack arg area so far. */ @@ -2548,7 +3617,7 @@ index 73b09e20508..d11c0ba21b4 100644 bool silent_p; /* True if we should act silently, rather than raise an error for invalid calls. */ } CUMULATIVE_ARGS; -@@ -1232,8 +1260,13 @@ extern const char *aarch64_rewrite_mcpu (int argc, const char **argv); +@@ -1242,8 +1270,13 @@ extern const char *aarch64_rewrite_mcpu (int argc, const char **argv); #define ASM_CPU_SPEC \ MCPU_TO_MARCH_SPEC @@ -2563,7 +3632,7 @@ index 73b09e20508..d11c0ba21b4 100644 #define ASM_OUTPUT_POOL_EPILOGUE aarch64_asm_output_pool_epilogue -@@ -1246,6 +1279,10 @@ extern GTY(()) tree aarch64_fp16_ptr_type_node; +@@ -1256,6 +1289,10 @@ extern GTY(()) tree aarch64_fp16_ptr_type_node; bfloat16_type_node. Defined in aarch64-builtins.cc. */ extern GTY(()) tree aarch64_bf16_ptr_type_node; @@ -2575,14 +3644,14 @@ index 73b09e20508..d11c0ba21b4 100644 So in order to unwind a function using a frame pointer, the very first function that is unwound must save the frame pointer. That way the frame diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md -index 36d0bb3f718..454c0fc1a8e 100644 +index 922cc987595..5c7c81548e1 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -304,6 +304,7 @@ UNSPEC_LD1RO UNSPEC_SALT_ADDR UNSPECV_PATCHABLE_AREA -+ UNSPEC_MACHOPIC_OFFSET ++ UNSPEC_MACHOPIC_OFFSET ; Common to Mach-O ports. ]) (define_c_enum "unspecv" [ @@ -2624,7 +3693,7 @@ index 36d0bb3f718..454c0fc1a8e 100644 (define_insn "trap" [(trap_if (const_int 1) (const_int 8))] "" -@@ -1304,7 +1336,7 @@ +@@ -1322,7 +1354,7 @@ ldr\\t%s0, %1 str\\t%w1, %0 str\\t%s1, %0 @@ -2633,7 +3702,7 @@ index 36d0bb3f718..454c0fc1a8e 100644 adr\\t%x0, %c1 adrp\\t%x0, %A1 fmov\\t%s0, %w1 -@@ -1342,7 +1374,7 @@ +@@ -1360,7 +1392,7 @@ ldr\\t%d0, %1 str\\t%x1, %0 str\\t%d1, %0 @@ -2642,13 +3711,53 @@ index 36d0bb3f718..454c0fc1a8e 100644 adr\\t%x0, %c1 adrp\\t%x0, %A1 fmov\\t%d0, %x1 -@@ -7019,7 +7051,10 @@ +@@ -1799,16 +1831,16 @@ + (set_attr "arch" "*,fp")] + ) + +-(define_insn "load_pair_dw_tftf" +- [(set (match_operand:TF 0 "register_operand" "=w") +- (match_operand:TF 1 "aarch64_mem_pair_operand" "Ump")) +- (set (match_operand:TF 2 "register_operand" "=w") +- (match_operand:TF 3 "memory_operand" "m"))] ++(define_insn "load_pair_dw_" ++ [(set (match_operand:TX 0 "register_operand" "=w") ++ (match_operand:TX 1 "aarch64_mem_pair_operand" "Ump")) ++ (set (match_operand:TX2 2 "register_operand" "=w") ++ (match_operand:TX2 3 "memory_operand" "m"))] + "TARGET_SIMD + && rtx_equal_p (XEXP (operands[3], 0), + plus_constant (Pmode, + XEXP (operands[1], 0), +- GET_MODE_SIZE (TFmode)))" ++ GET_MODE_SIZE (mode)))" + "ldp\\t%q0, %q2, %z1" + [(set_attr "type" "neon_ldp_q") + (set_attr "fp" "yes")] +@@ -1849,11 +1881,11 @@ + (set_attr "arch" "*,fp")] + ) + +-(define_insn "store_pair_dw_tftf" +- [(set (match_operand:TF 0 "aarch64_mem_pair_operand" "=Ump") +- (match_operand:TF 1 "register_operand" "w")) +- (set (match_operand:TF 2 "memory_operand" "=m") +- (match_operand:TF 3 "register_operand" "w"))] ++(define_insn "store_pair_dw_" ++ [(set (match_operand:TX 0 "aarch64_mem_pair_operand" "=Ump") ++ (match_operand:TX 1 "register_operand" "w")) ++ (set (match_operand:TX2 2 "memory_operand" "=m") ++ (match_operand:TX2 3 "register_operand" "w"))] + "TARGET_SIMD && + rtx_equal_p (XEXP (operands[2], 0), + plus_constant (Pmode, +@@ -7045,7 +7077,10 @@ (lo_sum:P (match_operand:P 1 "register_operand" "r") (match_operand 2 "aarch64_valid_symref" "S")))] "" - "add\\t%0, %1, :lo12:%c2" + { return TARGET_MACHO -+ ? "add\\t%0, %1, %K2;momd" ++ ? "add\\t%0, %1, %J2;" + : "add\\t%0, %1, :lo12:%c2"; + } [(set_attr "type" "alu_imm")] @@ -2701,10 +3810,10 @@ index 5b20abc27e5..9c6a631c6fb 100644 A constraint that matches an immediate offset valid for SVE LD1B diff --git a/gcc/config/aarch64/darwin.h b/gcc/config/aarch64/darwin.h new file mode 100644 -index 00000000000..5609c569dc1 +index 00000000000..08febf1401b --- /dev/null +++ b/gcc/config/aarch64/darwin.h -@@ -0,0 +1,279 @@ +@@ -0,0 +1,289 @@ +/* Target definitions for Arm64/Aarch64 running on macOS/iOS. + +Copyright The GNU Toolchain Authors. @@ -2733,15 +3842,20 @@ index 00000000000..5609c569dc1 +#undef DARWIN_ARM64 +#define DARWIN_ARM64 1 + -+/* FIXME FIXME FIXME - these are mostly guesses right now. */ -+ -+/* FIXME: this is only used in generic code in darwin.c. */ ++/* This is used in generic code in darwin.cc (at present, we have no support ++ for the arm64_32 target). */ +#undef TARGET_64BIT +#define TARGET_64BIT 1 + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "long int" + ++#undef TARGET_PROMOTE_FUNCTION_MODE ++#define TARGET_PROMOTE_FUNCTION_MODE aarch64_darwin_promote_fn_mode ++ ++#undef TARGET_PROMOTE_FUNCTION_MODE_CA ++#define TARGET_PROMOTE_FUNCTION_MODE_CA aarch64_darwin_promote_function_mode_ca ++ +/* NOTE that arm64_32 is a valid thing and corresponds to darwinpcs + and TARGET_ILP32, but we are not implementing that for now. */ +#define TARGET_OS_CPP_BUILTINS() \ @@ -2752,8 +3866,7 @@ index 00000000000..5609c569dc1 + darwin_cpp_builtins (pfile); \ + } while (0) + -+/* In Darwin's arm64 ABI, chars are signed, for consistency with other Darwin -+ architectures. */ ++/* In Darwin's Arm64 ABI, chars are signed. */ + +#undef DEFAULT_SIGNED_CHAR +#define DEFAULT_SIGNED_CHAR 1 @@ -2761,21 +3874,18 @@ index 00000000000..5609c569dc1 +#undef LONG_DOUBLE_TYPE_SIZE +#define LONG_DOUBLE_TYPE_SIZE 64 + -+/* Disable custom function descriptors on Darwin, it breaks ABI. */ ++/* Disable custom function descriptors on Darwin (we use heap-based ++ trampolines). */ +#undef AARCH64_CUSTOM_FUNCTION_TEST +#define AARCH64_CUSTOM_FUNCTION_TEST 0 + -+/* Non-PIE executables are forbidden by the aarch64-darwin security model; ++/* Non-PIE executables are forbidden by the Arm64-darwin security model; + remove the option from link-lines since they just produce a warning from + ld64 and are then ignored anyway. */ +#undef DARWIN_NOPIE_SPEC +#define DARWIN_NOPIE_SPEC \ +" % ++# include ++#endif ++ ++ ++#if TARGET_MACHO ++ ++/* Default architecture to use if -mcpu=native did not detect a known CPU. */ ++#define DEFAULT_ARCH "apple-m1" ++ ++/* macOS does not have /proc/cpuinfo and needs a different approach, ++ based on sysctl. It is much simpler. */ ++ ++const char * ++host_detect_local_cpu (ATTRIBUTE_UNUSED int argc, ATTRIBUTE_UNUSED const char **argv) ++{ ++ bool arch = false; ++ bool tune = false; ++ bool cpu = false; ++ const char *res = NULL; ++ uint32_t family; ++ size_t len = sizeof(family); ++ ++ gcc_assert (argc); ++ if (!argv[0]) ++ return NULL; ++ ++ /* Are we processing -march, mtune or mcpu? */ ++ arch = strcmp (argv[0], "arch") == 0; ++ if (!arch) ++ tune = strcmp (argv[0], "tune") == 0; ++ if (!arch && !tune) ++ cpu = strcmp (argv[0], "cpu") == 0; ++ if (!arch && !tune && !cpu) ++ return NULL; ++ ++ sysctlbyname("hw.cpufamily", &family, &len, NULL, 0); ++ ++ switch (family) ++ { ++ case 0x07d34b9f: // Vortex, Tempest ++ res = "apple-a12"; ++ break; ++ case 0x573b5eec: ++ case 0x1b588bb3: // Firestorm, Icestorm ++ res = "apple-m1"; ++ break; ++ case 0xda33d83d: // Blizzard, Avalanche ++ res = "apple-m2"; ++ break; ++ case 0xfa33415e: // Ibiza (M3) ++ case 0x5f4dea93: // Lobos (M3 Pro) ++ case 0x72015832: // Palma (M3 Max) ++ res = "apple-m3"; ++ break; ++ default: ++ res = DEFAULT_ARCH; ++ } ++ ++ if (res) ++ return concat ("-m", argv[0], "=", res, NULL); ++ else ++ return NULL; ++} ++ ++#else ++ + struct aarch64_arch_extension + { + const char *ext; +@@ -468,3 +536,4 @@ not_found: + } + } + ++#endif diff --git a/gcc/config/aarch64/falkor-tag-collision-avoidance.cc b/gcc/config/aarch64/falkor-tag-collision-avoidance.cc -index 39e3f5c2d1b..78790cd1d15 100644 +index 39e3f5c2d1b..9b3357f5952 100644 --- a/gcc/config/aarch64/falkor-tag-collision-avoidance.cc +++ b/gcc/config/aarch64/falkor-tag-collision-avoidance.cc @@ -740,7 +740,7 @@ dump_insn_list (const rtx &t, const insn_info_list_t &insn_info, @@ -2993,10 +4196,24 @@ index 39e3f5c2d1b..78790cd1d15 100644 { gcc_assert (dump_file); - fprintf (dump_file, "Tag 0x%lx ::\n", INTVAL (t)); -+ fprintf (dump_file, "Tag 0x%lx ::\n", (long unsigned int)INTVAL (t)); ++ fprintf (dump_file, "Tag 0x" HOST_WIDE_INT_PRINT_HEX_PURE " ::\n", INTVAL (t)); for (unsigned i = 0; i < insn_info.length (); i++) dump_insn_slim (dump_file, insn_info[i]->insn); +diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md +index 86a196d3536..0708a924745 100644 +--- a/gcc/config/aarch64/iterators.md ++++ b/gcc/config/aarch64/iterators.md +@@ -316,6 +316,9 @@ + ;; TX plus V16QImode. + (define_mode_iterator TX_V16QI [TI TF TD V16QI]) + ++;; Duplicate of TX above ++(define_mode_iterator TX2 [TI TF TD]) ++ + (define_mode_iterator VTX [TI TF TD V16QI V8HI V4SI V2DI V8HF V4SF V2DF V8BF]) + + ;; Advanced SIMD opaque structure modes. diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md index 3f5f4df8c46..4c3498dfe2c 100644 --- a/gcc/config/aarch64/predicates.md @@ -3028,7 +4245,7 @@ index 3f5f4df8c46..4c3498dfe2c 100644 }) diff --git a/gcc/config/aarch64/t-aarch64-darwin b/gcc/config/aarch64/t-aarch64-darwin new file mode 100644 -index 00000000000..9754e87ebcf +index 00000000000..e2b8ad9237f --- /dev/null +++ b/gcc/config/aarch64/t-aarch64-darwin @@ -0,0 +1,25 @@ @@ -3054,14 +4271,54 @@ index 00000000000..9754e87ebcf +LIB1ASMSRC = aarch64/lib1funcs.asm +LIB1ASMFUNCS = _aarch64_sync_cache_range + -+# FIXME - figure out what multilib provisions we should make for ++# TODO - figure out what multilib provisions we should make for +# a) arm64e +# b) arm64_32 +diff --git a/gcc/config/darwin-c.cc b/gcc/config/darwin-c.cc +index 579b9fa9317..10d5fb12d9b 100644 +--- a/gcc/config/darwin-c.cc ++++ b/gcc/config/darwin-c.cc +@@ -555,7 +555,7 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp) + return 0; + } + +-/* Given an OS X version VERSION_STR, return it as a statically-allocated array ++/* Given an macOS version VERSION_STR, return it as a statically-allocated array + of three integers. If VERSION_STR is invalid, return NULL. + + VERSION_STR must consist of one, two, or three tokens, each separated by +@@ -612,7 +612,7 @@ parse_version (const char *version_str) + return version_array; + } + +-/* Given VERSION -- a three-component OS X version represented as an array of ++/* Given VERSION -- a three-component macOS version represented as an array of + non-negative integers -- return a statically-allocated string suitable for + the legacy __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro. If VERSION + is invalid and cannot be coerced into a valid form, return NULL. +@@ -645,7 +645,7 @@ version_as_legacy_macro (const unsigned long *version) + return result; + } + +-/* Given VERSION -- a three-component OS X version represented as an array of ++/* Given VERSION -- a three-component macOS version represented as an array of + non-negative integers -- return a statically-allocated string suitable for + the modern __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro. If VERSION + is invalid, return NULL. +@@ -675,7 +675,7 @@ version_as_modern_macro (const unsigned long *version) + + /* Return the value of darwin_macosx_version_min, suitably formatted for the + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro. Values representing +- OS X 10.9 and earlier are encoded using the legacy four-character format, ++ macOS 10.9 and earlier are encoded using the legacy four-character format, + while 10.10 and later use a modern six-character format. (For example, + "10.9" produces "1090", and "10.10.1" produces "101001".) If + darwin_macosx_version_min is invalid and cannot be coerced into a valid diff --git a/gcc/config/darwin-driver.cc b/gcc/config/darwin-driver.cc -index 9c1dcc3d794..a4d7cfe7376 100644 +index 9c1dcc3d794..b2f39af9f68 100644 --- a/gcc/config/darwin-driver.cc +++ b/gcc/config/darwin-driver.cc -@@ -268,14 +268,21 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -268,10 +268,13 @@ darwin_driver_init (unsigned int *decoded_options_count, bool seenX86_64 = false; bool seenPPC = false; bool seenPPC64 = false; @@ -3075,15 +4332,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 const char *vers_string = NULL; bool seen_version_min = false; bool seen_sysroot_p = false; - bool noexport_p = true; -+#ifdef RPATH_SETS_NODEFAULT -+ bool seen_rpath_p = false; -+ bool seen_nodefaultrpaths_p = false; -+#endif - - for (i = 1; i < *decoded_options_count; i++) - { -@@ -296,6 +303,12 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -296,6 +299,12 @@ darwin_driver_init (unsigned int *decoded_options_count, seenPPC = true; else if (!strcmp ((*decoded_options)[i].arg, "ppc64")) seenPPC64 = true; @@ -3096,7 +4345,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 else error ("this compiler does not support %qs", (*decoded_options)[i].arg); -@@ -309,7 +322,7 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -309,7 +318,7 @@ darwin_driver_init (unsigned int *decoded_options_count, --i; --*decoded_options_count; break; @@ -3105,7 +4354,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 case OPT_m32: seenM32 = true; break; -@@ -317,6 +330,7 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -317,6 +326,7 @@ darwin_driver_init (unsigned int *decoded_options_count, case OPT_m64: seenM64 = true; break; @@ -3113,24 +4362,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 case OPT_mmacosx_version_min_: seen_version_min = true; -@@ -349,8 +363,16 @@ darwin_driver_init (unsigned int *decoded_options_count, - gcc_checking_assert ((*decoded_options)[i].arg); - if (startswith ((*decoded_options)[i].arg, "-exported_symbol")) - noexport_p = false; -+#ifdef RPATH_SETS_NODEFAULT -+ else if (strncmp ((*decoded_options)[i].arg, "-rpath", 6) == 0) -+ seen_rpath_p = true; -+#endif - break; - -+#ifdef RPATH_SETS_NODEFAULT -+ case OPT_nodefaultrpaths: -+ seen_nodefaultrpaths_p = true; -+#endif - default: - break; - } -@@ -366,6 +388,9 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -366,6 +376,9 @@ darwin_driver_init (unsigned int *decoded_options_count, if (seenPPC || seenPPC64) warning (0, "this compiler does not support PowerPC" " (%<-arch%> option ignored)"); @@ -3140,7 +4372,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 if (seenX86) { if (seenX86_64 || seenM64) -@@ -389,6 +414,9 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -389,6 +402,9 @@ darwin_driver_init (unsigned int *decoded_options_count, if (seenX86 || seenX86_64) warning (0, "this compiler does not support x86" " (%<-arch%> option ignored)"); @@ -3150,7 +4382,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 if (seenPPC) { if (seenPPC64 || seenM64) -@@ -408,12 +436,20 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -408,12 +424,20 @@ darwin_driver_init (unsigned int *decoded_options_count, if (! seenM64) /* Add -m64 if the User didn't. */ appendM64 = true; } @@ -3171,7 +4403,7 @@ index 9c1dcc3d794..a4d7cfe7376 100644 if (appendM32 || appendM64) { ++*decoded_options_count; -@@ -423,6 +459,7 @@ darwin_driver_init (unsigned int *decoded_options_count, +@@ -423,6 +447,7 @@ darwin_driver_init (unsigned int *decoded_options_count, generate_option (appendM32 ? OPT_m32 : OPT_m64, NULL, 1, CL_DRIVER, &(*decoded_options)[*decoded_options_count - 1]); } @@ -3179,28 +4411,72 @@ index 9c1dcc3d794..a4d7cfe7376 100644 if (!seen_sysroot_p) { -@@ -490,4 +527,16 @@ darwin_driver_init (unsigned int *decoded_options_count, - generate_option (OPT_nodefaultexport, NULL, 1, CL_DRIVER, - &(*decoded_options)[*decoded_options_count - 1]); +@@ -440,7 +465,7 @@ darwin_driver_init (unsigned int *decoded_options_count, + } } -+ -+#ifdef RPATH_SETS_NODEFAULT -+ if (seen_rpath_p && !seen_nodefaultrpaths_p) -+ { -+ ++*decoded_options_count; -+ *decoded_options = XRESIZEVEC (struct cl_decoded_option, -+ *decoded_options, -+ *decoded_options_count); -+ generate_option (OPT_nodefaultrpaths, NULL, 1, CL_DRIVER, -+ &(*decoded_options)[*decoded_options_count - 1]); -+ } -+#endif - } + +- /* We will need to know the OS X version we're trying to build for here ++ /* We will need to know the macOS version we're trying to build for here + so that we can figure out the mechanism and source for the sysroot to + be used. */ + if (!seen_version_min) +diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h +index 9df358ee7d3..babc8883b6e 100644 +--- a/gcc/config/darwin-protos.h ++++ b/gcc/config/darwin-protos.h +@@ -86,9 +86,12 @@ extern void darwin_asm_lto_end (void); + extern void darwin_mark_decl_preserved (const char *); + + extern tree darwin_handle_kext_attribute (tree *, tree, tree, int, bool *); +-extern tree darwin_handle_weak_import_attribute (tree *node, tree name, +- tree args, int flags, +- bool * no_add_attrs); ++extern tree darwin_handle_weak_import_attribute (tree *, tree, tree, int, ++ bool *); ++extern tree darwin_handle_availability_attribute (tree *, tree, tree, ++ int, bool *); ++extern bool darwin_attribute_takes_identifier_p (const_tree); ++ + extern void machopic_output_stub (FILE *, const char *, const char *); + extern void darwin_globalize_label (FILE *, const char *); + extern void darwin_assemble_visibility (tree, int); +@@ -124,6 +127,7 @@ extern void darwin_enter_string_into_cfstring_table (tree); + extern void darwin_asm_output_anchor (rtx symbol); + extern bool darwin_use_anchors_for_symbol_p (const_rtx symbol); + extern bool darwin_kextabi_p (void); ++extern bool darwin_unreachable_traps_p (void); + extern void darwin_override_options (void); + extern void darwin_patch_builtins (void); + extern void darwin_rename_builtins (void); diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc -index ced2f7e40a6..0915548477e 100644 +index 1471dbb6046..e95520f2a15 100644 --- a/gcc/config/darwin.cc +++ b/gcc/config/darwin.cc -@@ -118,7 +118,7 @@ static bool ld_init_term_start_labels = false; +@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see + #include "cfghooks.h" + #include "df.h" + #include "memmodel.h" ++#include "c-family/c-common.h" /* enum rid. */ + #include "tm_p.h" + #include "stringpool.h" + #include "attribs.h" +@@ -49,6 +50,7 @@ along with GCC; see the file COPYING3. If not see + #include "optabs.h" + #include "flags.h" + #include "opts.h" ++#include "c-family/c-objc.h" /* for objc_method_decl(). */ + + /* Fix and Continue. + +@@ -102,6 +104,7 @@ int darwin_running_cxx; + + /* Some code-gen now depends on OS major version numbers (at least). */ + int generating_for_darwin_version ; ++unsigned long current_os_version = 0; + + /* For older linkers we need to emit special sections (marked 'coalesced') for + for weak or single-definition items. */ +@@ -131,7 +134,7 @@ struct { section * darwin_sections[NUM_DARWIN_SECTIONS]; /* While we transition to using in-tests instead of ifdef'd code. */ @@ -3209,7 +4485,7 @@ index ced2f7e40a6..0915548477e 100644 #define gen_macho_high(m,a,b) (a) #define gen_macho_low(m,a,b,c) (a) #endif -@@ -1052,6 +1052,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) +@@ -1065,6 +1068,7 @@ machopic_legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) return pic_ref; } @@ -3217,7 +4493,7 @@ index ced2f7e40a6..0915548477e 100644 /* Callbacks to output the stub or non-lazy pointers. Each works on the item in *SLOT,if it has been used. DATA is the FILE* for assembly output. -@@ -1207,6 +1208,7 @@ machopic_finish (FILE *out_file) +@@ -1220,6 +1224,7 @@ machopic_finish (FILE *out_file) machopic_indirections->traverse_noresize (out_file); } @@ -3225,141 +4501,720 @@ index ced2f7e40a6..0915548477e 100644 int machopic_operand_p (rtx op) -@@ -2240,6 +2242,8 @@ darwin_emit_except_table_label (FILE *file) - rtx - darwin_make_eh_symbol_indirect (rtx orig, bool ARG_UNUSED (pubvis)) - { -+ if (DARWIN_ARM64) -+ return orig; - if (DARWIN_PPC == 0 && TARGET_64BIT) - return orig; - -@@ -3060,7 +3064,12 @@ darwin_file_end (void) - fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags); - } +@@ -2155,6 +2160,122 @@ darwin_handle_kext_attribute (tree *node, tree name, + return NULL_TREE; + } -+#if !DARWIN_ARM64 - machopic_finish (asm_out_file); -+#else -+ gcc_checking_assert (!machopic_indirections); -+#endif ++enum version_components { MAJOR, MINOR, TINY }; + - if (flag_apple_kext) - { - /* These sections are only used for kernel code. */ -diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h -index 1b538c73593..7fb3ec40755 100644 ---- a/gcc/config/darwin.h -+++ b/gcc/config/darwin.h -@@ -42,6 +42,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - - #define DARWIN_X86 0 - #define DARWIN_PPC 0 -+#define DARWIN_ARM64 0 - - #define OBJECT_FORMAT_MACHO 1 - -@@ -303,6 +304,31 @@ extern GTY(()) int darwin_ms_struct; - #define DARWIN_CC1_SPEC \ - "% 10.11 mmacosx-version-min= -lgcc_s.1.1) \ -+ %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) " -+#endif ++/* Parse a version number in x.y.z form and validate it as a macOS ++ version. Ideally, we'd put this in a common place usable by the ++ Darwin backend. */ + -+/* We might elect to add a path even when this compiler does not use embedded -+ run paths, so that we can use libraries from an alternate compiler that is -+ using embedded runpaths. */ -+#if DARWIN_DO_EXTRA_RPATH -+# define DARWIN_EXTRA_RPATH \ -+"%{!r:%{!nostdlib:%{!nodefaultrpaths:\ -+ %:version-compare(>= 10.5 mmacosx-version-min= -rpath) \ -+ %:version-compare(>= 10.5 mmacosx-version-min= " DARWIN_ADD_RPATH ") \ -+ }}}" -+#else -+# define DARWIN_EXTRA_RPATH "" -+#endif ++static bool ++parse_version (unsigned version_array[3], const char *version_str) ++{ ++ size_t version_len; ++ char *end, last = '\0', delimiter = '.', alt_delim = '_'; + - #define SUBSUBTARGET_OVERRIDE_OPTIONS \ - do { \ - darwin_override_options (); \ -@@ -396,7 +422,9 @@ extern GTY(()) int darwin_ms_struct; - DARWIN_NOPIE_SPEC \ - DARWIN_RDYNAMIC \ - DARWIN_NOCOMPACT_UNWIND \ -- "}}}}}}} % 10.6 mmacosx-version-min= -lgcc_eh) \ - %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w); \ - shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ -- %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \ -- %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) \ -+ " DARWIN_SHARED_LIBGCC " \ - %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \ - %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ - %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5); \ -@@ -547,7 +574,8 @@ extern GTY(()) int darwin_ms_struct; - { "darwin_crt2", DARWIN_CRT2_SPEC }, \ - { "darwin_crt3", DARWIN_CRT3_SPEC }, \ - { "darwin_dylib1", DARWIN_DYLIB1_SPEC }, \ -- { "darwin_bundle1", DARWIN_BUNDLE1_SPEC }, -+ { "darwin_bundle1", DARWIN_BUNDLE1_SPEC }, \ -+ { "darwin_rpaths", DARWIN_RPATH_SPEC }, - - #define DARWIN_CRT1_SPEC \ - "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \ -@@ -573,6 +601,17 @@ extern GTY(()) int darwin_ms_struct; - "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \ - %{fgnu-tm: -lcrttms.o}}" - -+#if DARWIN_AT_RPATH -+/* A default rpath, that picks up dependent libraries installed in the same -+ director as one being loaded. */ -+#define DARWIN_RPATH_SPEC \ -+ "%:version-compare(>= 10.5 mmacosx-version-min= -rpath) \ -+ %:version-compare(>= 10.5 mmacosx-version-min= @loader_path) \ -+ %P " -+#else -+#define DARWIN_RPATH_SPEC "" -+#endif ++ if (!version_str) ++ return false; + - #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION - /* Emit macosx version (but only major). */ - #define ASM_MMACOSX_VERSION_MIN_SPEC \ -diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt -index d655aaef2fb..ff624ffd82a 100644 ---- a/gcc/config/darwin.opt -+++ b/gcc/config/darwin.opt -@@ -241,6 +241,10 @@ nodefaultexport - Driver RejectNegative - Do not add a default symbol exports to modules or dynamic libraries. - -+nodefaultrpaths -+Driver RejectNegative -+Do not add default run paths (for the compiler library directories) to executables, modules or dynamic libraries. ++ /* Handle the odd situation in which we get STRING_CST which contain the ++ starting and ending quotes. */ ++ if (version_str[0] == '"') ++ { ++ version_str++; ++ version_len = strrchr (&version_str[1], '"') - version_str; ++ last = '"'; ++ } ++ else ++ version_len = strlen (version_str); ++ ++ if (version_len < 1) ++ return false; ++ ++ /* Version string must consist of digits and periods only. */ ++ if (strspn (version_str, "0123456789._") != version_len) ++ return false; ++ ++ if (!ISDIGIT (version_str[0]) || !ISDIGIT (version_str[version_len - 1])) ++ return false; ++ ++ version_array[MAJOR] = strtoul (version_str, &end, 10); ++ if (*end == '_') ++ { ++ delimiter = '_'; ++ alt_delim = '.'; ++ } ++ version_str = end + ((*end == delimiter) ? 1 : 0); ++ if (version_array[MAJOR] == 100000) ++ return true; ++ if (version_array[MAJOR] > 99) ++ return false; ++ ++ /* Version string must not contain adjacent delimiters. */ ++ if (*version_str == delimiter || *version_str == alt_delim) ++ return false; ++ ++ version_array[MINOR] = strtoul (version_str, &end, 10); ++ if (*end == alt_delim) ++ return false; ++ version_str = end + ((*end == delimiter) ? 1 : 0); ++ if (version_array[MINOR] > 99) ++ return false; ++ ++ version_array[TINY] = strtoul (version_str, &end, 10); ++ if (version_array[TINY] > 99) ++ return false; ++ ++ /* Version string must contain no more than three tokens. */ ++ if (*end != last) ++ return false; ++ ++ return true; ++} ++ ++/* Turn a version expressed as maj.min.tiny into an unsigned long ++ integer representing the value used in macOS availability macros. */ ++ ++static unsigned long ++version_from_version_array (unsigned vers[3]) ++{ ++ unsigned long res = 0; ++ /* There seems to be a special "unknown" value. */ ++ if (vers[0] == 100000) ++ return 999999; ++ ++ /* Here, we follow the 'modern' / 'legacy' numbering scheme for versions. */ ++ if (vers[0] > 10 || vers[1] >= 10) ++ res = vers[0] * 10000 + vers[1] * 100 + vers[2]; ++ else ++ { ++ res = vers[0] * 100; ++ if (vers[1] > 9) ++ res += 90; ++ else ++ res += vers[1] * 10; ++ if (vers[2] > 9) ++ res += 9; ++ else ++ res += vers[1]; ++ } ++ return res; ++} ++ ++/* Extract a macOS version from an availability attribute argument. */ ++ ++static unsigned long ++os_version_from_avail_value (tree value) ++{ ++ unsigned long res = 0; ++ unsigned vers[3] = {0,0,0}; ++ if (TREE_CODE (value) == STRING_CST) ++ { ++ if (parse_version (&vers[0], TREE_STRING_POINTER (value))) ++ res = version_from_version_array (&vers[0]); ++ } ++ else ++ gcc_unreachable (); ++ return res; ++} ++ + /* Handle a "weak_import" attribute; arguments as in + struct attribute_spec.handler. */ + +@@ -2176,6 +2297,231 @@ darwin_handle_weak_import_attribute (tree *node, tree name, + return NULL_TREE; + } + ++#define NUM_AV_OSES 13 ++const char *availability_os[NUM_AV_OSES] ++ = { "macos", "macosx", "ios", "tvos", "watchos", "driverkit", "swift", ++ "maccatalyst", "macCatalyst", "xros", "visionos", "android", "zos" }; ++ ++#define NUM_AV_CLAUSES 6 ++const char *availability_clause[NUM_AV_CLAUSES] ++ = { "unavailable", "introduced", "deprecated", "obsoleted", "message", ++ "replacement" }; ++ ++/* Validate and act upon the arguments to an 'availability' attribute. */ ++ ++tree ++darwin_handle_availability_attribute (tree *node, tree name, tree args, ++ int flags, bool * no_add_attrs) ++{ ++ tree decl = *node; ++ *no_add_attrs = true; ++ ++ if (!decl || (!TYPE_P (decl) && !DECL_P (decl))) ++ { ++ warning (OPT_Wattributes, "%qE attribute ignored", name); ++ return NULL_TREE; ++ } ++ else if (decl == error_mark_node) ++ return NULL_TREE; ++ ++ location_t loc = DECL_SOURCE_LOCATION (decl); ++ if (args == NULL_TREE) ++ { ++ error_at (loc, "%qE attribute requires at least one argument", ++ name); ++ return NULL_TREE; ++ } ++ else if (args == error_mark_node) ++ return NULL_TREE; ++ ++ /* The first argument must name a supported OS - although we could choose ++ to ignore any OS we don't recognise. */ ++ gcc_checking_assert (TREE_CODE (args) == TREE_LIST); ++ tree platform = TREE_VALUE (args); ++ if (platform == error_mark_node) ++ return NULL_TREE; ++ ++ gcc_checking_assert (TREE_CODE (platform) == IDENTIFIER_NODE); ++ bool platform_ok = false; ++ unsigned plat_num = 0; ++ for (; plat_num < (unsigned) NUM_AV_OSES; plat_num++) ++ if (strcmp (availability_os[plat_num], IDENTIFIER_POINTER (platform)) == 0) ++ { ++ platform_ok = true; ++ break; ++ } ++ if (!platform_ok) ++ { ++ error_at (input_location, ++ "platform %qE is not recognised for the % " ++ "attribute", platform); ++ return NULL_TREE; ++ } ++ else if (plat_num > 1) /* We only compile for macos so far. */ ++ return NULL_TREE; ++ ++ /* We might be dealing with an object or type. */ ++ tree target_decl = NULL_TREE; ++ tree type = NULL_TREE; ++ bool warn = false; ++ if (DECL_P (*node)) ++ { ++ type = TREE_TYPE (decl); ++ ++ if (TREE_CODE (decl) == TYPE_DECL ++ || TREE_CODE (decl) == PARM_DECL ++ || VAR_OR_FUNCTION_DECL_P (decl) ++ || TREE_CODE (decl) == FIELD_DECL ++ || TREE_CODE (decl) == CONST_DECL ++ /*|| objc_method_decl (TREE_CODE (decl))*/) ++ target_decl = decl; ++ else ++ warn = true; ++ } ++ else if (TYPE_P (*node)) ++ type = target_decl = *node; ++ else ++ warn = true; ++ ++ tree what = NULL_TREE; ++ if (warn) ++ { ++ if (type && TYPE_NAME (type)) ++ { ++ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) ++ what = TYPE_NAME (*node); ++ else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL ++ && DECL_NAME (TYPE_NAME (type))) ++ what = DECL_NAME (TYPE_NAME (type)); ++ } ++ if (what) ++ warning (OPT_Wattributes, "%qE attribute ignored for %qE", name, what); ++ else ++ warning (OPT_Wattributes, "%qE attribute ignored", name); ++ return NULL_TREE; ++ } ++ ++ /* Now we have to parse the availability clauses. */ ++ tree msg = NULL_TREE; ++ tree replacement = NULL_TREE; ++ bool unavailable = false; ++ unsigned introduced = 1000; ++ unsigned deprecated = current_os_version + 1; ++ unsigned obsoleted = current_os_version + 1; ++ for (tree arg = TREE_CHAIN (args); arg; arg = TREE_CHAIN (arg)) ++ { ++ tree clause_name = TREE_VALUE (arg); ++ tree clause_value = TREE_PURPOSE (arg); ++ if (clause_name == error_mark_node ++ || clause_value == error_mark_node) ++ continue; ++ unsigned clause_num = 0; ++ for (; clause_num < (unsigned) NUM_AV_CLAUSES; clause_num++) ++ if (strcmp (availability_clause[clause_num], ++ IDENTIFIER_POINTER (clause_name)) == 0) ++ break; ++ switch (clause_num) ++ { ++ default: ++ error_at (input_location, ++ "clause %qE is not recognised for the % " ++ "attribute", clause_name); ++ break; ++ case 0: ++ unavailable = true; ++ break; ++ case 1: ++ case 2: ++ case 3: ++ if (!clause_value) ++ error_at (input_location, "%<%E=%> requires a value", clause_name); ++ else ++ { ++ unsigned version = os_version_from_avail_value (clause_value); ++ if (version == 0) ++ error_at (input_location, "the value %qE provided to %qE is " ++ "not a valid OS version", clause_value, clause_name); ++ else if (clause_num == 1) ++ introduced = version; ++ else if (clause_num == 2) ++ deprecated = version; ++ else if (clause_num == 3) ++ obsoleted = version; ++ } ++ break; ++ case 4: ++ case 5: ++ if (!clause_value || TREE_CODE (clause_value) != STRING_CST) ++ error_at (input_location, "%<%E=%> requires a string", clause_name); ++ else if (clause_num == 4) ++ msg = clause_value; ++ else ++ replacement = clause_value; ++ break; ++ } ++ } ++ /* Now figure out what to do. */ ++ tree maybe_text = NULL_TREE; ++ if (replacement) ++ maybe_text = tree_cons (NULL_TREE, replacement, NULL_TREE); ++ else if (msg) ++ maybe_text = tree_cons (NULL_TREE, msg, NULL_TREE); ++ ++ if (unavailable || current_os_version >= obsoleted) ++ { ++ TREE_UNAVAILABLE (*node) = true; ++ /* We do not handle the availability attribute at diagnostics-time, so ++ if we want the informational messages, then attach them to additional ++ attributes for the deprecation or unavailability. TODO; maybe we can ++ fabricate the composite here. */ ++ if (maybe_text) ++ { ++ *no_add_attrs = false; ++ tree new_attr = tree_cons (get_identifier ("unavailable"), ++ maybe_text, NULL_TREE); ++ /* This is the actual consequence of the evaluation. */ ++ if (TYPE_P (target_decl) && !(flags & (int) ATTR_FLAG_TYPE_IN_PLACE)) ++ { ++ *node = build_variant_type_copy (*node); ++ TYPE_ATTRIBUTES (*node) = chainon (TYPE_ATTRIBUTES (*node), ++ new_attr); ++ } ++ else ++ DECL_ATTRIBUTES (*node) = chainon (DECL_ATTRIBUTES (*node), ++ new_attr); ++ } ++ } ++ else if (current_os_version > deprecated) ++ { ++ TREE_DEPRECATED (*node) = true; ++ if (maybe_text) ++ { ++ *no_add_attrs = false; ++ tree new_attr = tree_cons (get_identifier ("deprecated"), ++ maybe_text, NULL_TREE); ++ /* This is the actual consequence of the evaluation. */ ++ if (TYPE_P (target_decl) && !(flags & (int) ATTR_FLAG_TYPE_IN_PLACE)) ++ { ++ *node = build_variant_type_copy (*node); ++ TYPE_ATTRIBUTES (*node) = chainon (TYPE_ATTRIBUTES (*node), ++ new_attr); ++ } ++ else ++ DECL_ATTRIBUTES (*node) = chainon (DECL_ATTRIBUTES (*node), ++ new_attr); ++ } ++ } ++ else if (current_os_version < introduced) ++ *no_add_attrs = false; ++ return NULL_TREE; ++} ++ ++bool ++darwin_attribute_takes_identifier_p (const_tree attr_id) ++{ ++ return is_attribute_p ("availability", attr_id); ++} ++ + /* Emit a label for an FDE, making it global and/or weak if appropriate. + The third parameter is nonzero if this is for exception handling. + The fourth parameter is nonzero if this is just a placeholder for an +@@ -2267,6 +2613,8 @@ darwin_emit_except_table_label (FILE *file) + rtx + darwin_make_eh_symbol_indirect (rtx orig, bool ARG_UNUSED (pubvis)) + { ++ if (DARWIN_ARM64) ++ return orig; + if (DARWIN_PPC == 0 && TARGET_64BIT) + return orig; + +@@ -3115,7 +3463,12 @@ darwin_file_end (void) + fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags); + } + ++#if !DARWIN_ARM64 + machopic_finish (asm_out_file); ++#else ++ gcc_checking_assert (!machopic_indirections); ++#endif ++ + if (flag_apple_kext) + { + /* These sections are only used for kernel code. */ +@@ -3291,6 +3644,13 @@ darwin_kextabi_p (void) { + return flag_apple_kext; + } + ++/* True, iff we want to map __builtin_unreachable to a trap. */ ++ ++bool ++darwin_unreachable_traps_p (void) { ++ return darwin_unreachable_traps; ++} ++ + void + darwin_override_options (void) + { +@@ -3311,7 +3671,14 @@ darwin_override_options (void) + generating_for_darwin_version = 8; + + /* Earlier versions are not specifically accounted, until required. */ ++ unsigned vers[3] = {0,0,0}; ++ if (!parse_version (vers, darwin_macosx_version_min)) ++ error_at (UNKNOWN_LOCATION, "how did we get a bad OS version? (%s)", ++ darwin_macosx_version_min); ++ current_os_version = version_from_version_array (vers); + } ++ else ++ current_os_version = 1058; + + /* Some codegen needs to account for the capabilities of the target + linker. */ +diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h +index 5c6c38ddc63..fcf9eff27d3 100644 +--- a/gcc/config/darwin.h ++++ b/gcc/config/darwin.h +@@ -1,4 +1,4 @@ +-/* Target definitions for Darwin (Mac OS X) systems. ++/* Target definitions for Darwin (macOS) systems. + Copyright (C) 1989-2023 Free Software Foundation, Inc. + Contributed by Apple Computer Inc. + +@@ -27,7 +27,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define CONFIG_DARWIN_H + + /* The definitions in this file are common to all processor types +- running Darwin, which is the kernel for Mac OS X. Darwin is ++ running Darwin, which is the kernel for macOS. Darwin is + basically a BSD user layer laid over a Mach kernel, then evolved + for many years (at NeXT) in parallel with other Unix systems. So + while the runtime is a somewhat idiosyncratic Mach-based thing, +@@ -42,6 +42,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + #define DARWIN_X86 0 + #define DARWIN_PPC 0 ++#define DARWIN_ARM64 0 + + #define OBJECT_FORMAT_MACHO 1 + +@@ -133,10 +134,9 @@ extern GTY(()) int darwin_ms_struct; + cases where these driver opts are used multiple times, or to control + operations on more than one command (e.g. dynamiclib). These are handled + specially and we then add %= 10.7 mmacosx-version-min= -no_pie) }" + + #define DARWIN_CC1_SPEC \ +- "% 10.11 mmacosx-version-min= -lgcc_s.1.1)" ++# define DARWIN_SHARED_WEAK_ADDS \ ++"%{%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w): \ ++ " DARWIN_HEAP_T_LIB "}" ++#endif ++ ++ ++/* We might elect to add a path even when this compiler does not use embedded ++ run paths, so that we can use libraries from an alternate compiler that is ++ using embedded runpaths. */ ++#if DARWIN_DO_EXTRA_RPATH ++# define DARWIN_EXTRA_RPATH \ ++"%{!r:%{!nostdlib:%{!nodefaultrpaths:\ ++ %:version-compare(>= 10.5 mmacosx-version-min= -rpath) \ ++ %:version-compare(>= 10.5 mmacosx-version-min= " DARWIN_ADD_RPATH ") \ ++ }}}" ++#else ++# define DARWIN_EXTRA_RPATH "" ++#endif + + #define SUBSUBTARGET_OVERRIDE_OPTIONS \ + do { \ +@@ -336,7 +372,8 @@ extern GTY(()) int darwin_ms_struct; + */ + + #define DARWIN_NOCOMPACT_UNWIND \ +-" %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) " ++"%{!fuse-ld=lld: \ ++ %:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind)}" + + /* In Darwin linker specs we can put -lcrt0.o and ld will search the library + path for crt0.o or -lcrtx.a and it will search for libcrtx.a. As for +@@ -356,10 +393,12 @@ extern GTY(()) int darwin_ms_struct; + #define LINK_COMMAND_SPEC_A \ + "%{!c:%{!E:%{!S:%{!M:%{!MM:%{!fsyntax-only:%{!fdump=*: \ + %(linker)" \ ++ DARWIN_LD_DEMANGLE \ + LINK_PLUGIN_SPEC \ + "%{flto*:% 10.6 mmacosx-version-min= -lgcc_eh); \ + shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ +- %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \ ++ " DARWIN_SHARED_LIBGCC " \ + %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh) \ + %:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \ + %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \ +@@ -520,18 +561,19 @@ extern GTY(()) int darwin_ms_struct; + + #define DARWIN_WEAK_CRTS \ + "%{static-libgcc|static: \ +- %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w) ; \ +- shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \ +- %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) ; \ +- : -lemutls_w \ ++ %{%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w): \ ++ " DARWIN_HEAP_T_LIB "} ; \ ++ shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: " \ ++ DARWIN_SHARED_WEAK_ADDS " ; \ ++ : -lemutls_w " DARWIN_HEAP_T_LIB " \ + }" + + /* We specify crt0.o as -lcrt0.o so that ld will search the library path. */ + + #undef STARTFILE_SPEC + #define STARTFILE_SPEC \ +-"%{dynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \ +- %{!dynamiclib:%{bundle:%(darwin_bundle1)} \ ++"%{dynamiclib|shared: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \ ++ %{!dynamiclib:%{!shared:%{bundle:%(darwin_bundle1)} \ + %{!bundle:%{pg:%{static:-lgcrt0.o} \ + %{!static:%{object:-lgcrt0.o} \ + %{!object:%{preload:-lgcrt0.o} \ +@@ -542,8 +584,8 @@ extern GTY(()) int darwin_ms_struct; + %{!static:%{object:-lcrt0.o} \ + %{!object:%{preload:-lcrt0.o} \ + %{!preload: %(darwin_crt1) \ +- %(darwin_crt2)}}}}}} \ +- %(darwin_crt3) % 10.5 mmacosx-version-min= -lcrt1.o) \ +@@ -580,6 +623,16 @@ extern GTY(()) int darwin_ms_struct; + "%{!static:%:version-compare(< 10.6 mmacosx-version-min= -lbundle1.o) \ + %{fgnu-tm: -lcrttms.o}}" + ++#if DARWIN_AT_RPATH ++/* A default rpath, that picks up dependent libraries installed in the same ++ director as one being loaded. */ ++#define DARWIN_RPATH_SPEC \ ++ "%:version-compare(>= 10.5 mmacosx-version-min= -rpath) \ ++ %{%:version-compare(>= 10.5 mmacosx-version-min= @loader_path): %P }" ++#else ++#define DARWIN_RPATH_SPEC "" ++#endif ++ + #ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION + /* Emit macosx version (but only major). */ + #define ASM_MMACOSX_VERSION_MIN_SPEC \ +@@ -927,7 +980,12 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS]; + { "apple_kext_compatibility", 0, 0, false, true, false, false, \ + darwin_handle_kext_attribute, NULL }, \ + { "weak_import", 0, 0, true, false, false, false, \ +- darwin_handle_weak_import_attribute, NULL } ++ darwin_handle_weak_import_attribute, NULL }, \ ++ { "availability", 0, -1, true, false, false, false, \ ++ darwin_handle_availability_attribute, NULL } ++ ++#undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P ++#define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P darwin_attribute_takes_identifier_p + + /* Make local constant labels linker-visible, so that if one follows a + weak_global constant, ld64 will be able to separate the atoms. */ +@@ -1175,6 +1233,10 @@ void add_framework_path (char *); + #define TARGET_N_FORMAT_TYPES 1 + #define TARGET_FORMAT_TYPES darwin_additional_format_types + ++/* We want __builtin_unreachable to be expanded as a trap instruction. */ ++#undef TARGET_UNREACHABLE_SHOULD_TRAP ++#define TARGET_UNREACHABLE_SHOULD_TRAP darwin_unreachable_traps_p ++ + #ifndef USED_FOR_TARGET + extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); + #define GCC_DRIVER_HOST_INITIALIZATION \ +diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt +index d655aaef2fb..97b1a747918 100644 +--- a/gcc/config/darwin.opt ++++ b/gcc/config/darwin.opt +@@ -91,6 +91,10 @@ mtarget-linker + Target RejectNegative Joined Separate Var(darwin_target_linker) Init(LD64_VERSION) + -mtarget-linker Specify that ld64 is the toolchain linker for the current invocation. + ++munreachable-traps ++Target Var(darwin_unreachable_traps) Init(1) ++When set (the default) this makes __builtin_unreachable render as a trap. ++ + ; Driver options. + + all_load +@@ -241,6 +245,10 @@ nodefaultexport + Driver RejectNegative + Do not add a default symbol exports to modules or dynamic libraries. + ++nodefaultrpaths ++Driver RejectNegative ++Do not add default run paths (for the compiler library directories) to executables, modules or dynamic libraries. + nofixprebinding Driver RejectNegative (Obsolete after 10.3.9) Set MH_NOPREFIXBINDING, in an executable. diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h -index 588bd669bdd..b6c9a94c3a0 100644 +index 588bd669bdd..657ea470683 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h -@@ -308,3 +308,10 @@ along with GCC; see the file COPYING3. If not see +@@ -121,6 +121,9 @@ along with GCC; see the file COPYING3. If not see + #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC + #endif + ++#undef DARWIN_HEAP_T_LIB ++#define DARWIN_HEAP_T_LIB " -lheapt_w " ++ + #undef SUBTARGET_EXTRA_SPECS + #define SUBTARGET_EXTRA_SPECS \ + DARWIN_EXTRA_SPECS \ +@@ -308,3 +311,9 @@ along with GCC; see the file COPYING3. If not see #define CLEAR_INSN_CACHE(beg, end) \ extern void sys_icache_invalidate(void *start, size_t len); \ sys_icache_invalidate ((beg), (size_t)((end)-(beg))) @@ -3368,13 +5223,12 @@ index 588bd669bdd..b6c9a94c3a0 100644 + trampolines. */ +#undef X86_CUSTOM_FUNCTION_TEST +#define X86_CUSTOM_FUNCTION_TEST \ -+ (!flag_off_stack_trampolines && !flag_trampolines) ? 1 : 0 -+ ++ (flag_trampolines && flag_trampoline_impl == TRAMPOLINE_IMPL_HEAP) ? 0 : 1 diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc -index a551b8b9d9b..dd9f22b440f 100644 +index 499184166ff..be6d408031b 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc -@@ -25189,7 +25189,7 @@ ix86_libgcc_floating_mode_supported_p +@@ -25245,7 +25245,7 @@ ix86_libgcc_floating_mode_supported_p #define TARGET_HARD_REGNO_SCRATCH_OK ix86_hard_regno_scratch_ok #undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS @@ -3384,7 +5238,7 @@ index a551b8b9d9b..dd9f22b440f 100644 #undef TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID #define TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID ix86_addr_space_zero_address_valid diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h -index 27b9783cae8..f97d3027da3 100644 +index 539083f2fbf..77644b0ed1d 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -754,6 +754,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); @@ -3400,8 +5254,39 @@ index 27b9783cae8..f97d3027da3 100644 /* C++ stores the virtual bit in the lowest bit of function pointers. */ #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_pfn +diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h +index 4d5d6f6d5a8..3a2e480ace6 100644 +--- a/gcc/config/rs6000/darwin.h ++++ b/gcc/config/rs6000/darwin.h +@@ -98,7 +98,7 @@ + Include libmx when targeting Darwin 7.0 and above, but before libSystem, + since the functions are actually in libSystem but for 7.x compatibility + we want them to be looked for in libmx first. +- Include libSystemStubs when compiling against 10.3 - 10.5 SDKs (we assume ++ Include libSystemStubs when compiling against 10.3 - 10.6 SDKs (we assume + this is the case when targetting these) - but not for 64-bit long double. + Don't do either for m64, the library is either a dummy or non-existent. + */ +@@ -107,12 +107,15 @@ + #define LIB_SPEC \ + "%{!static: \ + %{!m64:%{!mlong-double-64: \ +- %{pg:%:version-compare(>< 10.3 10.5 mmacosx-version-min= -lSystemStubs_profile)} \ +- %{!pg:%:version-compare(>< 10.3 10.5 mmacosx-version-min= -lSystemStubs)} \ ++ %{pg:%:version-compare(>< 10.3 10.7 mmacosx-version-min= -lSystemStubs_profile)} \ ++ %{!pg:%:version-compare(>< 10.3 10.7 mmacosx-version-min= -lSystemStubs)} \ + %:version-compare(>< 10.3 10.4 mmacosx-version-min= -lmx)}} \ + -lSystem \ + }" + ++#undef DARWIN_HEAP_T_LIB ++#define DARWIN_HEAP_T_LIB " " ++ + /* We want -fPIC by default, unless we're using -static to compile for + the kernel or some such. The "-faltivec" option should have been + called "-maltivec" all along. */ diff --git a/gcc/configure b/gcc/configure -index c7b26d1927d..f4bd9c5d5f1 100755 +index ade0af23e8c..4af01a09637 100755 --- a/gcc/configure +++ b/gcc/configure @@ -632,10 +632,10 @@ ac_includes_default="\ @@ -3418,7 +5303,14 @@ index c7b26d1927d..f4bd9c5d5f1 100755 enable_host_shared enable_plugin pluginlibs -@@ -740,6 +740,8 @@ ORIGINAL_PLUGIN_LD_FOR_TARGET +@@ -735,11 +735,15 @@ ORIGINAL_NM_FOR_TARGET + gcc_cv_nm + ORIGINAL_LD_GOLD_FOR_TARGET + ORIGINAL_LD_BFD_FOR_TARGET ++ORIGINAL_CLASSIC_LD_FOR_TARGET ++ORIGINAL_LLD_FOR_TARGET + ORIGINAL_LD_FOR_TARGET + ORIGINAL_PLUGIN_LD_FOR_TARGET gcc_cv_ld ORIGINAL_AS_FOR_TARGET gcc_cv_as @@ -3427,7 +5319,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 enable_fast_install objdir OTOOL64 -@@ -1003,6 +1005,8 @@ enable_static +@@ -1004,6 +1008,8 @@ enable_static with_pic enable_fast_install enable_libtool_lock @@ -3436,7 +5328,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 enable_ld enable_gold with_plugin_ld -@@ -1028,6 +1032,7 @@ enable_link_serialization +@@ -1029,6 +1035,7 @@ enable_link_serialization enable_version_specific_runtime_libs enable_plugin enable_host_shared @@ -3444,16 +5336,17 @@ index c7b26d1927d..f4bd9c5d5f1 100755 enable_libquadmath_support with_linker_hash_style with_diagnostics_color -@@ -1736,6 +1741,8 @@ Optional Features: +@@ -1742,6 +1749,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-ld[=ARG] build ld [ARG={default,yes,no}] --enable-gold[=ARG] build gold [ARG={default,yes,no}] --enable-gnu-indirect-function -@@ -1790,6 +1797,7 @@ Optional Features: +@@ -1796,6 +1806,7 @@ Optional Features: in a compiler-specific directory --enable-plugin enable plugin support --enable-host-shared build host code as shared libraries @@ -3461,7 +5354,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 --disable-libquadmath-support disable libquadmath support for Fortran --enable-default-pie enable Position Independent Executable as default -@@ -1854,6 +1862,9 @@ Optional Packages: +@@ -1860,6 +1871,9 @@ Optional Packages: --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] @@ -3471,80 +5364,58 @@ index c7b26d1927d..f4bd9c5d5f1 100755 --with-plugin-ld=[ARG] specify the plugin linker --with-glibc-version=M.N assume GCC used with glibc version M.N or later -@@ -3753,33 +3764,59 @@ gcc_gxx_libcxx_include_dir= +@@ -3759,20 +3773,19 @@ gcc_gxx_libcxx_include_dir= # Check whether --with-gxx-libcxx-include-dir was given. if test "${with_gxx_libcxx_include_dir+set}" = set; then : - withval=$with_gxx_libcxx_include_dir; case "${withval}" in -yes) as_fn_error $? "bad value ${withval} given for libc++ include directory" "$LINENO" 5 ;; --no) ;; -*) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;; -esac + withval=$with_gxx_libcxx_include_dir; gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir fi -+# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. -+# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. + # --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. + # if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. +# if --with-gxx-libcxx-include-dir is 'yes' we enable the stdlib option and use +# the default path within the installation. -+# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option + # if --with-gxx-libcxx-include-dir is unset we enable the stdlib option +-# based on the platform (to be available on platform versions where it is the +# based on the platform (to be available on platform versions where it is the -+# default for the system tools). We also use a default path within the compiler + # default for the system tools). We also use a default path within the compiler +-# install tree. +-# Otherwise, we use the path provided and enable the stdlib option. +# install tree. +# Otherwise, we use the path provided and enable the stdlib option. # If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we # check to see if the latter starts with the former and, upon success, compute # gcc_gxx_libcxx_include_dir as relative to the sysroot. - gcc_gxx_libcxx_include_dir_add_sysroot=0 -- -+gcc_enable_stdlib_opt=0 +@@ -3780,16 +3793,20 @@ gcc_gxx_libcxx_include_dir_add_sysroot=0 + gcc_enable_stdlib_opt=0 if test x${gcc_gxx_libcxx_include_dir} != x; then -+ if test x${gcc_gxx_libcxx_include_dir} = xno; then + if test x${gcc_gxx_libcxx_include_dir} = xno; then +- # set defaults for the dir, but the option is disabled anyway. + # set defaults for the dir, but the option is disabled anyway. -+ gcc_gxx_libcxx_include_dir= + gcc_gxx_libcxx_include_dir= + elif test x${gcc_gxx_libcxx_include_dir} = xyes; then + # set defaults for the dir, and enable. + gcc_gxx_libcxx_include_dir= + gcc_enable_stdlib_opt=1 -+ else -+ gcc_enable_stdlib_opt=1 -+ fi -+else -+ case $target in -+ *-darwin1[1-9]* | *-darwin2*) + else + gcc_enable_stdlib_opt=1 + fi + else + case $target in + *-darwin1[1-9]* | *-darwin2*) +- # Default this on for Darwin versions which default to libcxx, +- # and embed the path in the compiler install so that we get a + # Default this on for Darwin versions which default to libcxx, + # and embed the path in the compiler install so that we get a -+ # self-contained toolchain. -+ gcc_enable_stdlib_opt=1 -+ ;; -+ *) ;; -+ esac -+fi - --$as_echo "#define ENABLE_STDLIB_OPTION 1" >>confdefs.h -+cat >>confdefs.h <<_ACEOF -+#define ENABLE_STDLIB_OPTION $gcc_enable_stdlib_opt -+_ACEOF - --else -- $as_echo "#define ENABLE_STDLIB_OPTION 0" >>confdefs.h - --fi --# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO. -+# Sysroot behaviour as for gxx-include-dir - if test x${gcc_gxx_libcxx_include_dir} = x; then -+ # default path,embedded in the compiler tree. -+ libcxx_incdir='include/c++/v1' - if test x${enable_version_specific_runtime_libs} = xyes; then -- gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1' -+ gcc_gxx_libcxx_include_dir='${libsubdir}/$libcxx_incdir' - else -- libcxx_incdir='libc++_include/c++/$(version)/v1' - if test x$host != x$target; then - libcxx_incdir="$target_alias/$libcxx_incdir" - fi -@@ -16295,7 +16332,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } + # self-contained toolchain. + gcc_enable_stdlib_opt=1 + ;; +@@ -16341,7 +16358,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -3553,7 +5424,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -18000,6 +18037,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -18046,6 +18063,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -3603,7 +5474,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -18017,9 +18097,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -18063,9 +18123,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -3619,25 +5490,25 @@ index c7b26d1927d..f4bd9c5d5f1 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -19825,7 +19909,7 @@ else +@@ -19871,7 +19935,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF --#line 19828 "configure" -+#line 19912 "configure" +-#line 19874 "configure" ++#line 19938 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -19931,7 +20015,7 @@ else +@@ -19977,7 +20041,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF --#line 19934 "configure" -+#line 20018 "configure" +-#line 19980 "configure" ++#line 20044 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -20807,6 +20891,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -20853,6 +20917,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -3687,7 +5558,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -20824,12 +20951,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -20870,12 +20977,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -3711,7 +5582,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -23200,6 +23335,35 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +@@ -23246,6 +23361,35 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu @@ -3747,7 +5618,69 @@ index c7b26d1927d..f4bd9c5d5f1 100755 # Identify the assembler which will work hand-in-glove with the newly # built GCC, so that we can examine its features. This is the assembler # which will be driven by the driver program. -@@ -32062,13 +32226,17 @@ fi +@@ -23522,6 +23666,14 @@ fi + $as_echo "$gold_non_default" >&6; } + + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld ++if test x"$ld64_flag" = x"yes"; then ++ORIGINAL_LLD_FOR_TARGET=${gcc_cv_ld}64.lld ++else ++ORIGINAL_LLD_FOR_TARGET=$gcc_cv_lld ++fi ++ORIGINAL_CLASSIC_LD_FOR_TARGET=$gcc_cv_ld-classic ++ ++ + + case "$ORIGINAL_LD_FOR_TARGET" in + ./collect-ld | ./collect-ld$build_exeext) ;; +@@ -30638,6 +30790,7 @@ if test x"$ld64_flag" = x"yes"; then + # Set defaults for possibly untestable items. + gcc_cv_ld64_export_dynamic=0 + gcc_cv_ld64_platform_version=0 ++ gcc_cv_ld64_demangle=0 + + if test "$build" = "$host"; then + darwin_try_test=1 +@@ -30661,6 +30814,9 @@ $as_echo_n "checking ld64 specified version... " >&6; } + gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_major" >&5 + $as_echo "$gcc_cv_ld64_major" >&6; } ++ if test "$gcc_cv_ld64_major" -ge 97; then ++ gcc_cv_ld64_demangle=1 ++ fi + if test "$gcc_cv_ld64_major" -ge 236; then + gcc_cv_ld64_export_dynamic=1 + fi +@@ -30678,6 +30834,15 @@ $as_echo_n "checking linker version... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_version" >&5 + $as_echo "$gcc_cv_ld64_version" >&6; } + ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -demangle support" >&5 ++$as_echo_n "checking linker for -demangle support... " >&6; } ++ gcc_cv_ld64_demangle=1 ++ if $gcc_cv_ld -demangle < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then ++ gcc_cv_ld64_demangle=0 ++ fi ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld64_demangle" >&5 ++$as_echo "$gcc_cv_ld64_demangle" >&6; } ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for -export_dynamic support" >&5 + $as_echo_n "checking linker for -export_dynamic support... " >&6; } + gcc_cv_ld64_export_dynamic=1 +@@ -30706,6 +30871,12 @@ _ACEOF + fi + + ++cat >>confdefs.h <<_ACEOF ++#define LD64_HAS_DEMANGLE $gcc_cv_ld64_demangle ++_ACEOF ++ ++ ++ + cat >>confdefs.h <<_ACEOF + #define LD64_HAS_EXPORT_DYNAMIC $gcc_cv_ld64_export_dynamic + _ACEOF +@@ -32251,13 +32422,17 @@ fi # Enable --enable-host-shared # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" = set; then : @@ -3768,7 +5701,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 # Check whether --enable-libquadmath-support was given. -@@ -32222,10 +32390,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +@@ -32411,10 +32586,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5 $as_echo "$gcc_cv_c_no_fpie" >&6; } @@ -3779,7 +5712,7 @@ index c7b26d1927d..f4bd9c5d5f1 100755 # Check if -no-pie works. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5 -@@ -32250,10 +32414,27 @@ rm -f core conftest.err conftest.$ac_objext \ +@@ -32439,11 +32610,28 @@ rm -f core conftest.err conftest.$ac_objext \ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5 $as_echo "$gcc_cv_no_pie" >&6; } @@ -3794,22 +5727,23 @@ index c7b26d1927d..f4bd9c5d5f1 100755 + PICFLAG=-fno-PIE +else + PICFLAG= - fi - ++fi ++ +if test x$enable_host_pie = xyes; then + LD_PICFLAG=-pie +elif test x$gcc_cv_no_pie = xyes; then + LD_PICFLAG=-no-pie +else + LD_PICFLAG= -+fi -+ + fi + + + + - # Enable Intel CET on Intel CET enabled host if jit is enabled. # Check whether --enable-cet was given. -@@ -32737,6 +32918,10 @@ LTLIBOBJS=$ac_ltlibobjs + if test "${enable_cet+set}" = set; then : +@@ -32926,6 +33114,10 @@ LTLIBOBJS=$ac_ltlibobjs @@ -3821,78 +5755,59 @@ index c7b26d1927d..f4bd9c5d5f1 100755 : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/gcc/configure.ac b/gcc/configure.ac -index 09082e8ccae..d181e41154c 100644 +index bf8ff4d6390..8c2ff477635 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -235,29 +235,54 @@ gcc_gxx_libcxx_include_dir= +@@ -235,18 +235,17 @@ gcc_gxx_libcxx_include_dir= AC_ARG_WITH(gxx-libcxx-include-dir, [AS_HELP_STRING([--with-gxx-libcxx-include-dir=DIR], [specifies directory to find libc++ header files])], -[case "${withval}" in -yes) AC_MSG_ERROR(bad value ${withval} given for libc++ include directory) ;; --no) ;; -*) gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir ;; -esac]) -- +[gcc_gxx_libcxx_include_dir=$with_gxx_libcxx_include_dir]) -+ -+# --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. -+# if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. + + # --with-gxx-libcxx-include-dir controls the enabling of the -stdlib option. + # if --with-gxx-libcxx-include-dir is 'no' we disable the stdlib option. +# if --with-gxx-libcxx-include-dir is 'yes' we enable the stdlib option and use +# the default path within the installation. -+# if --with-gxx-libcxx-include-dir is unset we enable the stdlib option + # if --with-gxx-libcxx-include-dir is unset we enable the stdlib option +-# based on the platform (to be available on platform versions where it is the +# based on the platform (to be available on platform versions where it is the -+# default for the system tools). We also use a default path within the compiler + # default for the system tools). We also use a default path within the compiler +-# install tree. +-# Otherwise, we use the path provided and enable the stdlib option. +# install tree. +# Otherwise, we use the path provided and enable the stdlib option. # If both --with-sysroot and --with-gxx-libcxx-include-dir are passed, we # check to see if the latter starts with the former and, upon success, compute # gcc_gxx_libcxx_include_dir as relative to the sysroot. - gcc_gxx_libcxx_include_dir_add_sysroot=0 -- -+gcc_enable_stdlib_opt=0 +@@ -254,16 +253,20 @@ gcc_gxx_libcxx_include_dir_add_sysroot=0 + gcc_enable_stdlib_opt=0 if test x${gcc_gxx_libcxx_include_dir} != x; then -- AC_DEFINE(ENABLE_STDLIB_OPTION, 1, -- [Define if the -stdlib= option should be enabled.]) -+ if test x${gcc_gxx_libcxx_include_dir} = xno; then + if test x${gcc_gxx_libcxx_include_dir} = xno; then +- # set defaults for the dir, but the option is disabled anyway. + # set defaults for the dir, but the option is disabled anyway. + gcc_gxx_libcxx_include_dir= + elif test x${gcc_gxx_libcxx_include_dir} = xyes; then + # set defaults for the dir, and enable. -+ gcc_gxx_libcxx_include_dir= -+ gcc_enable_stdlib_opt=1 -+ else + gcc_gxx_libcxx_include_dir= + gcc_enable_stdlib_opt=1 -+ fi + else + gcc_enable_stdlib_opt=1 + fi else -- AC_DEFINE(ENABLE_STDLIB_OPTION, 0) -+ case $target in -+ *-darwin1[[1-9]]* | *-darwin2*) + case $target in + *-darwin1[[1-9]]* | *-darwin2*) +- # Default this on for Darwin versions which default to libcxx, +- # and embed the path in the compiler install so that we get a + # Default this on for Darwin versions which default to libcxx, + # and embed the path in the compiler install so that we get a -+ # self-contained toolchain. -+ gcc_enable_stdlib_opt=1 -+ ;; -+ *) ;; -+ esac - fi --# ??? This logic must match libstdc++-v3/acinclude.m4:GLIBCXX_EXPORT_INSTALL_INFO. -+AC_DEFINE_UNQUOTED(ENABLE_STDLIB_OPTION, $gcc_enable_stdlib_opt, -+ [Define if the -stdlib= option should be enabled.]) -+ -+# Sysroot behaviour as for gxx-include-dir - if test x${gcc_gxx_libcxx_include_dir} = x; then -+ # default path,embedded in the compiler tree. -+ libcxx_incdir='include/c++/v1' - if test x${enable_version_specific_runtime_libs} = xyes; then -- gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1' -+ gcc_gxx_libcxx_include_dir='${libsubdir}/$libcxx_incdir' - else -- libcxx_incdir='libc++_include/c++/$(version)/v1' - if test x$host != x$target; then - libcxx_incdir="$target_alias/$libcxx_incdir" - fi -@@ -2586,6 +2611,21 @@ AC_PROG_LIBTOOL + # self-contained toolchain. + gcc_enable_stdlib_opt=1 + ;; +@@ -2625,6 +2628,21 @@ AC_PROG_LIBTOOL AC_SUBST(objdir) AC_SUBST(enable_fast_install) @@ -3914,7 +5829,74 @@ index 09082e8ccae..d181e41154c 100644 # Identify the assembler which will work hand-in-glove with the newly # built GCC, so that we can examine its features. This is the assembler # which will be driven by the driver program. -@@ -7400,11 +7440,14 @@ fi +@@ -2797,7 +2815,15 @@ fi + AC_MSG_RESULT($gold_non_default) + + ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld ++if test x"$ld64_flag" = x"yes"; then ++ORIGINAL_LLD_FOR_TARGET=${gcc_cv_ld}64.lld ++else ++ORIGINAL_LLD_FOR_TARGET=$gcc_cv_lld ++fi ++ORIGINAL_CLASSIC_LD_FOR_TARGET=$gcc_cv_ld-classic + AC_SUBST(ORIGINAL_LD_FOR_TARGET) ++AC_SUBST(ORIGINAL_LLD_FOR_TARGET) ++AC_SUBST(ORIGINAL_CLASSIC_LD_FOR_TARGET) + case "$ORIGINAL_LD_FOR_TARGET" in + ./collect-ld | ./collect-ld$build_exeext) ;; + *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;; +@@ -4793,7 +4819,7 @@ foo: nop + gcc_cv_as_mllvm_x86_pad_for_align, + [-mllvm -x86-pad-for-align=false], [.text],, + [AC_DEFINE(HAVE_AS_MLLVM_X86_PAD_FOR_ALIGN, 1, +- [Define if your Mac OS X assembler supports -mllvm -x86-pad-for-align=false.])]) ++ [Define if your macOS assembler supports -mllvm -x86-pad-for-align=false.])]) + ;; + esac + +@@ -6273,6 +6299,7 @@ if test x"$ld64_flag" = x"yes"; then + # Set defaults for possibly untestable items. + gcc_cv_ld64_export_dynamic=0 + gcc_cv_ld64_platform_version=0 ++ gcc_cv_ld64_demangle=0 + + if test "$build" = "$host"; then + darwin_try_test=1 +@@ -6294,6 +6321,9 @@ if test x"$ld64_flag" = x"yes"; then + AC_MSG_CHECKING(ld64 specified version) + gcc_cv_ld64_major=`echo "$gcc_cv_ld64_version" | sed -e 's/\..*//'` + AC_MSG_RESULT($gcc_cv_ld64_major) ++ if test "$gcc_cv_ld64_major" -ge 97; then ++ gcc_cv_ld64_demangle=1 ++ fi + if test "$gcc_cv_ld64_major" -ge 236; then + gcc_cv_ld64_export_dynamic=1 + fi +@@ -6309,6 +6339,13 @@ if test x"$ld64_flag" = x"yes"; then + fi + AC_MSG_RESULT($gcc_cv_ld64_version) + ++ AC_MSG_CHECKING(linker for -demangle support) ++ gcc_cv_ld64_demangle=1 ++ if $gcc_cv_ld -demangle < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then ++ gcc_cv_ld64_demangle=0 ++ fi ++ AC_MSG_RESULT($gcc_cv_ld64_demangle) ++ + AC_MSG_CHECKING(linker for -export_dynamic support) + gcc_cv_ld64_export_dynamic=1 + if $gcc_cv_ld -export_dynamic < /dev/null 2>&1 | grep 'unknown option' > /dev/null; then +@@ -6329,6 +6366,9 @@ if test x"$ld64_flag" = x"yes"; then + [Define to ld64 version.]) + fi + ++ AC_DEFINE_UNQUOTED(LD64_HAS_DEMANGLE, $gcc_cv_ld64_demangle, ++ [Define to 1 if ld64 supports '-demangle'.]) ++ + AC_DEFINE_UNQUOTED(LD64_HAS_EXPORT_DYNAMIC, $gcc_cv_ld64_export_dynamic, + [Define to 1 if ld64 supports '-export_dynamic'.]) + +@@ -7479,11 +7519,14 @@ fi # Enable --enable-host-shared AC_ARG_ENABLE(host-shared, [AS_HELP_STRING([--enable-host-shared], @@ -3932,7 +5914,7 @@ index 09082e8ccae..d181e41154c 100644 AC_ARG_ENABLE(libquadmath-support, [AS_HELP_STRING([--disable-libquadmath-support], -@@ -7526,10 +7569,6 @@ AC_CACHE_CHECK([for -fno-PIE option], +@@ -7605,10 +7648,6 @@ AC_CACHE_CHECK([for -fno-PIE option], [gcc_cv_c_no_fpie=yes], [gcc_cv_c_no_fpie=no]) CXXFLAGS="$saved_CXXFLAGS"]) @@ -3943,7 +5925,7 @@ index 09082e8ccae..d181e41154c 100644 # Check if -no-pie works. AC_CACHE_CHECK([for -no-pie option], -@@ -7540,10 +7579,27 @@ AC_CACHE_CHECK([for -no-pie option], +@@ -7619,10 +7658,27 @@ AC_CACHE_CHECK([for -no-pie option], [gcc_cv_no_pie=yes], [gcc_cv_no_pie=no]) LDFLAGS="$saved_LDFLAGS"]) @@ -3974,11 +5956,218 @@ index 09082e8ccae..d181e41154c 100644 # Enable Intel CET on Intel CET enabled host if jit is enabled. GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) +diff --git a/gcc/coretypes.h b/gcc/coretypes.h +index ca8837cef67..7e022a427c4 100644 +--- a/gcc/coretypes.h ++++ b/gcc/coretypes.h +@@ -199,6 +199,12 @@ enum tls_model { + TLS_MODEL_LOCAL_EXEC + }; + ++/* Types of trampoline implementation. */ ++enum trampoline_impl { ++ TRAMPOLINE_IMPL_STACK, ++ TRAMPOLINE_IMPL_HEAP ++}; ++ + /* Types of ABI for an offload compiler. */ + enum offload_abi { + OFFLOAD_ABI_UNSET, +diff --git a/gcc/cp/cp-lang.cc b/gcc/cp/cp-lang.cc +index 2f541460c4a..84200a9a04a 100644 +--- a/gcc/cp/cp-lang.cc ++++ b/gcc/cp/cp-lang.cc +@@ -121,6 +121,15 @@ objcp_tsubst_copy_and_build (tree /*t*/, + return NULL_TREE; + } + ++/* Implement c-family hook to add language-specific features ++ for __has_{feature,extension}. */ ++ ++void ++c_family_register_lang_features () ++{ ++ cp_register_features (); ++} ++ + static const char * + cxx_dwarf_name (tree t, int verbosity) + { +diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc +index 93b027b80ce..10b9b35a1c0 100644 +--- a/gcc/cp/cp-objcp-common.cc ++++ b/gcc/cp/cp-objcp-common.cc +@@ -23,10 +23,153 @@ along with GCC; see the file COPYING3. If not see + #include "coretypes.h" + #include "cp-tree.h" + #include "cp-objcp-common.h" ++#include "c-family/c-common.h" + #include "dwarf2.h" + #include "stringpool.h" + #include "contracts.h" + ++/* Class to determine whether a given C++ language feature is available. ++ Used to implement __has_{feature,extension}. */ ++ ++struct cp_feature_selector ++{ ++ enum ++ { ++ DIALECT, ++ FLAG ++ } kind; ++ ++ enum class result ++ { ++ NONE, ++ EXT, ++ FEAT ++ }; ++ ++ union ++ { ++ const int *enable_flag; ++ struct { ++ enum cxx_dialect feat; ++ enum cxx_dialect ext; ++ } dialect; ++ }; ++ ++ constexpr cp_feature_selector (const int *flag) ++ : kind (FLAG), enable_flag (flag) {} ++ constexpr cp_feature_selector (enum cxx_dialect feat, ++ enum cxx_dialect ext) ++ : kind (DIALECT), dialect{feat, ext} {} ++ constexpr cp_feature_selector (enum cxx_dialect feat) ++ : cp_feature_selector (feat, feat) {} ++ ++ inline result has_feature () const; ++}; ++ ++/* Check whether this language feature is available as a feature, ++ extension, or not at all. */ ++ ++cp_feature_selector::result ++cp_feature_selector::has_feature () const ++{ ++ switch (kind) ++ { ++ case DIALECT: ++ if (cxx_dialect >= dialect.feat) ++ return result::FEAT; ++ else if (cxx_dialect >= dialect.ext) ++ return result::EXT; ++ else ++ return result::NONE; ++ case FLAG: ++ return *enable_flag ? result::FEAT : result::NONE; ++ } ++ ++ gcc_unreachable (); ++} ++ ++/* Information about a C++ language feature which can be queried ++ through __has_{feature,extension}. IDENT is the name of the feature, ++ and SELECTOR encodes how to compute whether the feature is available. */ ++ ++struct cp_feature_info ++{ ++ const char *ident; ++ cp_feature_selector selector; ++}; ++ ++/* Table of features for __has_{feature,extension}. */ ++ ++static constexpr cp_feature_info cp_feature_table[] = ++{ ++ { "cxx_exceptions", &flag_exceptions }, ++ { "cxx_rtti", &flag_rtti }, ++ { "cxx_access_control_sfinae", { cxx11, cxx98 } }, ++ { "cxx_alias_templates", cxx11 }, ++ { "cxx_alignas", cxx11 }, ++ { "cxx_alignof", cxx11 }, ++ { "cxx_attributes", cxx11 }, ++ { "cxx_constexpr", cxx11 }, ++ { "cxx_decltype", cxx11 }, ++ { "cxx_decltype_incomplete_return_types", cxx11 }, ++ { "cxx_default_function_template_args", cxx11 }, ++ { "cxx_defaulted_functions", cxx11 }, ++ { "cxx_delegating_constructors", cxx11 }, ++ { "cxx_deleted_functions", cxx11 }, ++ { "cxx_explicit_conversions", cxx11 }, ++ { "cxx_generalized_initializers", cxx11 }, ++ { "cxx_implicit_moves", cxx11 }, ++ { "cxx_inheriting_constructors", cxx11 }, ++ { "cxx_inline_namespaces", { cxx11, cxx98 } }, ++ { "cxx_lambdas", cxx11 }, ++ { "cxx_local_type_template_args", cxx11 }, ++ { "cxx_noexcept", cxx11 }, ++ { "cxx_nonstatic_member_init", cxx11 }, ++ { "cxx_nullptr", cxx11 }, ++ { "cxx_override_control", cxx11 }, ++ { "cxx_reference_qualified_functions", cxx11 }, ++ { "cxx_range_for", cxx11 }, ++ { "cxx_raw_string_literals", cxx11 }, ++ { "cxx_rvalue_references", cxx11 }, ++ { "cxx_static_assert", cxx11 }, ++ { "cxx_thread_local", cxx11 }, ++ { "cxx_auto_type", cxx11 }, ++ { "cxx_strong_enums", cxx11 }, ++ { "cxx_trailing_return", cxx11 }, ++ { "cxx_unicode_literals", cxx11 }, ++ { "cxx_unrestricted_unions", cxx11 }, ++ { "cxx_user_literals", cxx11 }, ++ { "cxx_variadic_templates", { cxx11, cxx98 } }, ++ { "cxx_binary_literals", { cxx14, cxx98 } }, ++ { "cxx_contextual_conversions", { cxx14, cxx98 } }, ++ { "cxx_decltype_auto", cxx14 }, ++ { "cxx_aggregate_nsdmi", cxx14 }, ++ { "cxx_init_captures", { cxx14, cxx11 } }, ++ { "cxx_generic_lambdas", cxx14 }, ++ { "cxx_relaxed_constexpr", cxx14 }, ++ { "cxx_return_type_deduction", cxx14 }, ++ { "cxx_variable_templates", cxx14 }, ++ { "modules", &flag_modules }, ++}; ++ ++/* Register C++ language features for __has_{feature,extension}. */ ++ ++void ++cp_register_features () ++{ ++ using result = cp_feature_selector::result; ++ ++ for (unsigned i = 0; i < ARRAY_SIZE (cp_feature_table); i++) ++ { ++ const cp_feature_info *info = cp_feature_table + i; ++ const auto res = info->selector.has_feature (); ++ if (res == result::NONE) ++ continue; ++ ++ c_common_register_feature (info->ident, res == result::FEAT); ++ } ++} ++ + /* Special routine to get the alias set for C++. */ + + alias_set_type +diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h +index 80893aa1752..9d4d873deb7 100644 +--- a/gcc/cp/cp-objcp-common.h ++++ b/gcc/cp/cp-objcp-common.h +@@ -34,6 +34,7 @@ extern tree cp_classtype_as_base (const_tree); + extern tree cp_get_global_decls (); + extern tree cp_pushdecl (tree); + extern void cp_register_dumps (gcc::dump_manager *); ++extern void cp_register_features (); + extern bool cp_handle_option (size_t, const char *, HOST_WIDE_INT, int, + location_t, const struct cl_option_handlers *); + extern tree cxx_make_type_hook (tree_code); diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc -index 1dd3c2b13bc..3d75d0099ed 100644 +index 36e1f2ce300..213e52c70e4 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc -@@ -3703,9 +3703,8 @@ get_tls_init_fn (tree var) +@@ -3712,9 +3712,8 @@ get_tls_init_fn (tree var) if (!flag_extern_tls_init && DECL_EXTERNAL (var)) return NULL_TREE; @@ -3990,7 +6179,7 @@ index 1dd3c2b13bc..3d75d0099ed 100644 return get_local_tls_init_fn (DECL_SOURCE_LOCATION (var)); tree sname = mangle_tls_init_fn (var); -@@ -3868,6 +3867,25 @@ generate_tls_wrapper (tree fn) +@@ -3877,6 +3876,25 @@ generate_tls_wrapper (tree fn) expand_or_defer_fn (finish_function (/*inline_p=*/false)); } @@ -4016,7 +6205,7 @@ index 1dd3c2b13bc..3d75d0099ed 100644 /* Start a global constructor or destructor function. */ static tree -@@ -4657,22 +4675,24 @@ handle_tls_init (void) +@@ -4666,22 +4684,24 @@ handle_tls_init (void) finish_expr_stmt (cp_build_modify_expr (loc, guard, NOP_EXPR, boolean_true_node, tf_warning_or_error)); @@ -4048,7 +6237,7 @@ index 1dd3c2b13bc..3d75d0099ed 100644 } } -@@ -4680,6 +4700,30 @@ handle_tls_init (void) +@@ -4689,6 +4709,30 @@ handle_tls_init (void) finish_if_stmt (if_stmt); finish_function_body (body); expand_or_defer_fn (finish_function (/*inline_p=*/false)); @@ -4079,7 +6268,7 @@ index 1dd3c2b13bc..3d75d0099ed 100644 } /* We're at the end of compilation, so generate any mangling aliases that -@@ -5098,7 +5142,14 @@ c_parse_final_cleanups (void) +@@ -5107,7 +5151,14 @@ c_parse_final_cleanups (void) } if (!DECL_INITIAL (decl) && decl_tls_wrapper_p (decl)) @@ -4095,6 +6284,290 @@ index 1dd3c2b13bc..3d75d0099ed 100644 if (!DECL_SAVED_TREE (decl)) continue; +diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc +index 4e67da6ff3a..1f1b76234b4 100644 +--- a/gcc/cp/parser.cc ++++ b/gcc/cp/parser.cc +@@ -694,6 +694,91 @@ cp_lexer_handle_early_pragma (cp_lexer *lexer) + static cp_parser *cp_parser_new (cp_lexer *); + static GTY (()) cp_parser *the_parser; + ++/* Context-sensitive parse-checking for clang-style attributes. */ ++ ++enum clang_attr_state { ++ CA_NONE = 0, ++ CA_ATTR, ++ CA_BR1, CA_BR2, ++ CA_LIST, ++ CA_LIST_ARGS, ++ CA_IS_CA, ++ CA_CA_ARGS, ++ CA_LIST_CONT ++}; ++ ++/* State machine tracking context of attribute lexing. */ ++ ++static enum clang_attr_state ++cp_lexer_attribute_state (cp_token& token, enum clang_attr_state attr_state) ++{ ++ /* Implement a context-sensitive parser for clang attributes. ++ We detect __attribute__((clang_style_attribute (ARGS))) and lex the ++ args ARGS with the following differences from GNU attributes: ++ (a) number-like values are lexed as strings [this allows lexing XX.YY.ZZ ++ version numbers]. ++ (b) we concatenate strings, since clang attributes allow this too. */ ++ switch (attr_state) ++ { ++ case CA_NONE: ++ if (token.type == CPP_KEYWORD ++ && token.keyword == RID_ATTRIBUTE) ++ attr_state = CA_ATTR; ++ break; ++ case CA_ATTR: ++ if (token.type == CPP_OPEN_PAREN) ++ attr_state = CA_BR1; ++ else ++ attr_state = CA_NONE; ++ break; ++ case CA_BR1: ++ if (token.type == CPP_OPEN_PAREN) ++ attr_state = CA_BR2; ++ else ++ attr_state = CA_NONE; ++ break; ++ case CA_BR2: ++ if (token.type == CPP_NAME) ++ { ++ tree identifier = (token.type == CPP_KEYWORD) ++ /* For keywords, use the canonical spelling, not the ++ parsed identifier. */ ++ ? ridpointers[(int) token.keyword] ++ : token.u.value; ++ identifier = canonicalize_attr_name (identifier); ++ if (attribute_clang_form_p (identifier)) ++ attr_state = CA_IS_CA; ++ else ++ attr_state = CA_LIST; ++ } ++ else ++ attr_state = CA_NONE; ++ break; ++ case CA_IS_CA: ++ case CA_LIST: ++ if (token.type == CPP_COMMA) ++ attr_state = CA_BR2; /* Back to the list outer. */ ++ else if (token.type == CPP_OPEN_PAREN) ++ attr_state = attr_state == CA_IS_CA ? CA_CA_ARGS ++ : CA_LIST_ARGS; ++ else ++ attr_state = CA_NONE; ++ break; ++ case CA_CA_ARGS: /* We will special-case args in this state. */ ++ case CA_LIST_ARGS: ++ if (token.type == CPP_CLOSE_PAREN) ++ attr_state = CA_LIST_CONT; ++ break; ++ case CA_LIST_CONT: ++ if (token.type == CPP_COMMA) ++ attr_state = CA_BR2; /* Back to the list outer. */ ++ else ++ attr_state = CA_NONE; ++ break; ++ } ++ return attr_state; ++} ++ + /* Create a new main C++ lexer, the lexer that gets tokens from the + preprocessor, and also create the main parser. */ + +@@ -710,6 +795,8 @@ cp_lexer_new_main (void) + c_common_no_more_pch (); + + cp_lexer *lexer = cp_lexer_alloc (); ++ enum clang_attr_state attr_state = CA_NONE; ++ + /* Put the first token in the buffer. */ + cp_token *tok = lexer->buffer->quick_push (token); + +@@ -733,8 +820,14 @@ cp_lexer_new_main (void) + if (tok->type == CPP_PRAGMA_EOL) + cp_lexer_handle_early_pragma (lexer); + ++ attr_state = cp_lexer_attribute_state (*tok, attr_state); + tok = vec_safe_push (lexer->buffer, cp_token ()); +- cp_lexer_get_preprocessor_token (C_LEX_STRING_NO_JOIN, tok); ++ unsigned int flags = C_LEX_STRING_NO_JOIN; ++ /* If we are processing clang-style attribute args, lex numbers as ++ potential version strings; NN .. NN.MM .. NN.MM.OO */ ++ if (attr_state == CA_CA_ARGS) ++ flags |= C_LEX_NUMBER_AS_STRING; ++ cp_lexer_get_preprocessor_token (flags, tok); + } + + lexer->next_token = lexer->buffer->address (); +@@ -936,7 +1029,7 @@ cp_lexer_get_preprocessor_token (unsigned flags, cp_token *token) + { + static int is_extern_c = 0; + +- /* Get a new token from the preprocessor. */ ++ /* Get a new token from the preprocessor. */ + token->type + = c_lex_with_flags (&token->u.value, &token->location, &token->flags, + flags); +@@ -20992,11 +21085,13 @@ cp_parser_enum_specifier (cp_parser* parser) + + /* Check for the `:' that denotes a specified underlying type in C++0x. + Note that a ':' could also indicate a bitfield width, however. */ ++ location_t colon_loc = UNKNOWN_LOCATION; + if (cp_lexer_next_token_is (parser->lexer, CPP_COLON)) + { + cp_decl_specifier_seq type_specifiers; + + /* Consume the `:'. */ ++ colon_loc = cp_lexer_peek_token (parser->lexer)->location; + cp_lexer_consume_token (parser->lexer); + + auto tdf +@@ -21045,10 +21140,13 @@ cp_parser_enum_specifier (cp_parser* parser) + && cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) + { + if (has_underlying_type) +- cp_parser_commit_to_tentative_parse (parser); +- cp_parser_error (parser, "expected %<;%> or %<{%>"); +- if (has_underlying_type) +- return error_mark_node; ++ pedwarn (colon_loc, ++ OPT_Welaborated_enum_base, ++ "declaration of enumeration with " ++ "fixed underlying type and no enumerator list is " ++ "only permitted as a standalone declaration"); ++ else ++ cp_parser_error (parser, "expected %<;%> or %<{%>"); + } + } + +@@ -29051,6 +29149,91 @@ cp_parser_gnu_attributes_opt (cp_parser* parser) + return attributes; + } + ++/* Parse the arguments list for a clang attribute. */ ++static tree ++cp_parser_clang_attribute (cp_parser *parser, tree/*attr_id*/) ++{ ++ /* Each entry can be : ++ identifier ++ identifier=N.MM.Z ++ identifier="string" ++ followed by ',' or ) for the last entry*/ ++ ++ matching_parens parens; ++ if (!parens.require_open (parser)) ++ return NULL; ++ ++ bool save_translate_strings_p = parser->translate_strings_p; ++ parser->translate_strings_p = false; ++ tree attr_args = NULL_TREE; ++ cp_token *token; ++ do ++ { ++ tree name = NULL_TREE; ++ tree value = NULL_TREE; ++ ++ token = cp_lexer_peek_token (parser->lexer); ++ if (token->type == CPP_NAME) ++ name = token->u.value; ++ else if (token->type == CPP_KEYWORD) ++ name = ridpointers[(int) token->keyword]; ++ else if (token->flags & NAMED_OP) ++ name = get_identifier (cpp_type2name (token->type, token->flags)); ++ else ++ { ++ /* FIXME: context-sensitive for that attrib. */ ++ error_at (token->location, "expected an attribute keyword"); ++ cp_parser_skip_to_closing_parenthesis (parser, ++ /*recovering=*/true, ++ /*or_comma=*/false, ++ /*consume_paren=*/false); ++ attr_args = error_mark_node; ++ break; ++ } ++ cp_lexer_consume_token (parser->lexer); ++ ++ if (cp_lexer_next_token_is (parser->lexer, CPP_EQ)) ++ { ++ cp_lexer_consume_token (parser->lexer); /* eat the '=' */ ++ if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN) ++ && cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)) ++ { ++ token = cp_lexer_peek_token (parser->lexer); ++ if (token->type == CPP_STRING) ++ value = cp_parser_string_literal (parser, /*translate=*/false, ++ /*wide_ok=*/false); ++ else ++ { ++ value = token->u.value; ++ cp_lexer_consume_token (parser->lexer); ++ } ++ } ++ /* else value is missing. */ ++ } ++ else if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN) ++ && cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)) ++ { ++ error_at (token->location, "expected %<,%>, %<=%> or %<)%>"); ++ cp_parser_skip_to_closing_parenthesis (parser, ++ /*recovering=*/true, ++ /*or_comma=*/false, ++ /*consume_paren=*/false); ++ attr_args = error_mark_node; ++ break; ++ } ++ if (cp_lexer_next_token_is (parser->lexer, CPP_COMMA)) ++ cp_lexer_consume_token (parser->lexer); ++ tree t = tree_cons (value, name, NULL_TREE); ++ attr_args = chainon (attr_args, t); ++ } while (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)); ++ ++ parser->translate_strings_p = save_translate_strings_p; ++ if (!parens.require_close (parser)) ++ return error_mark_node; ++ ++ return attr_args; ++} ++ + /* Parse a GNU attribute-list. + + attribute-list: +@@ -29110,9 +29293,12 @@ cp_parser_gnu_attribute_list (cp_parser* parser, bool exactly_one /* = false */) + + /* Peek at the next token. */ + token = cp_lexer_peek_token (parser->lexer); +- /* If it's an `(', then parse the attribute arguments. */ +- if (token->type == CPP_OPEN_PAREN) ++ if (token->type == CPP_OPEN_PAREN ++ && attribute_clang_form_p (identifier)) ++ arguments = cp_parser_clang_attribute (parser, identifier); ++ else if (token->type == CPP_OPEN_PAREN) + { ++ /* If it's an `(', then parse the attribute arguments. */ + vec *vec; + int attr_flag = (attribute_takes_identifier_p (identifier) + ? id_attr : normal_attr); +@@ -29129,12 +29315,12 @@ cp_parser_gnu_attribute_list (cp_parser* parser, bool exactly_one /* = false */) + arguments = build_tree_list_vec (vec); + release_tree_vector (vec); + } +- /* Save the arguments away. */ +- TREE_VALUE (attribute) = arguments; + } + + if (arguments != error_mark_node) + { ++ /* Save the arguments away. */ ++ TREE_VALUE (attribute) = arguments; + /* Add this attribute to the list. */ + TREE_CHAIN (attribute) = attribute_list; + attribute_list = attribute; diff --git a/gcc/cumulative-args.h b/gcc/cumulative-args.h new file mode 100644 index 00000000000..b60928e37f9 @@ -4134,8 +6607,102 @@ index 1679fb81097..4fbf2096416 100644 DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++ +diff --git a/gcc/doc/contrib.texi b/gcc/doc/contrib.texi +index 758805dc5db..f8f002cdc8e 100644 +--- a/gcc/doc/contrib.texi ++++ b/gcc/doc/contrib.texi +@@ -1515,7 +1515,7 @@ Gael Thomas for @code{VMClassLoader} boot packages support suggestions. + + @item + Andreas Tobler for Darwin and Solaris testing and fixing, @code{Qt4} +-support for Darwin/OS X, @code{Graphics2D} support, @code{gtk+} ++support for Darwin / macOS, @code{Graphics2D} support, @code{gtk+} + updates. + + @item +diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi +index b0a2ce3ac6b..f57278dd2e8 100644 +--- a/gcc/doc/cpp.texi ++++ b/gcc/doc/cpp.texi +@@ -3198,6 +3198,8 @@ directive}: @samp{#if}, @samp{#ifdef} or @samp{#ifndef}. + * @code{__has_cpp_attribute}:: + * @code{__has_c_attribute}:: + * @code{__has_builtin}:: ++* @code{__has_feature}:: ++* @code{__has_extension}:: + * @code{__has_include}:: + @end menu + +@@ -3560,6 +3562,45 @@ the operator is as follows: + #endif + @end smallexample + ++@node @code{__has_feature} ++@subsection @code{__has_feature} ++@cindex @code{__has_feature} ++ ++The special operator @code{__has_feature (@var{operand})} may be used in ++constant integer contexts and in preprocessor @samp{#if} and @samp{#elif} ++expressions to test whether the identifier given in @var{operand} is recognized ++as a feature supported by GCC given the current options and, in the case of ++standard language features, whether the feature is available in the chosen ++version of the language standard. ++ ++Note that @code{__has_feature} and @code{__has_extension} are not recommended ++for use in new code, and are only provided for compatibility with Clang. For ++details of which identifiers are accepted by these function-like macros, see ++@w{@uref{https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension, ++the Clang documentation}}. ++ ++@node @code{__has_extension} ++@subsection @code{__has_extension} ++@cindex @code{__has_extension} ++ ++The special operator @code{__has_extension (@var{operand})} may be used in ++constant integer contexts and in preprocessor @samp{#if} and @samp{#elif} ++expressions to test whether the identifier given in @var{operand} is recognized ++as an extension supported by GCC given the current options. In any given ++context, the features accepted by @code{__has_extension} are a strict superset ++of those accepted by @code{__has_feature}. Unlike @code{__has_feature}, ++@code{__has_extension} tests whether a given feature is available regardless of ++strict language standards conformance. ++ ++If the @option{-pedantic-errors} flag is given, @code{__has_extension} is ++equivalent to @code{__has_feature}. ++ ++Note that @code{__has_feature} and @code{__has_extension} are not recommended ++for use in new code, and are only provided for compatibility with Clang. For ++details of which identifiers are accepted by these function-like macros, see ++@w{@uref{https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension, ++the Clang documentation}}. ++ + @node @code{__has_include} + @subsection @code{__has_include} + @cindex @code{__has_include} +diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi +index d6fcd611339..a16375085d5 100644 +--- a/gcc/doc/extend.texi ++++ b/gcc/doc/extend.texi +@@ -23797,7 +23797,7 @@ attribute, do change the value of preprocessor macros like + + The following pragmas are available for all architectures running the + Darwin operating system. These are useful for compatibility with other +-Mac OS compilers. ++macOS compilers. + + @table @code + @cindex pragma, mark +@@ -24976,7 +24976,7 @@ compiled separately. + @end table + + G++ implements the Borland model on targets where the linker supports it, +-including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows. ++including ELF targets (such as GNU/Linux), macOS and Microsoft Windows. + Otherwise G++ implements neither automatic model. + + You have the following options for dealing with template instantiations: diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi -index b30d3691fe6..93d5236f7b3 100644 +index b30d3691fe6..de05d1c42da 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1075,14 +1075,26 @@ code. @@ -4167,21 +6734,155 @@ index b30d3691fe6..93d5236f7b3 100644 @item @anchor{with-gnu-as}--with-gnu-as Specify that the compiler should assume that the assembler it finds is the GNU assembler. However, this does not modify +@@ -1790,6 +1802,12 @@ particularly useful if you intend to use several versions of GCC in + parallel. The default is @samp{yes} for @samp{libada}, and @samp{no} for + the remaining libraries. + ++@item --with-darwin-extra-rpath ++This is provided to allow distributions to add a single additional ++runpath on Darwin / macOS systems. This allows for cases where the ++installed GCC library directories are then symlinked to a common ++directory outside of the GCC installation. ++ + @item @anchor{WithAixSoname}--with-aix-soname=@samp{aix}, @samp{svr4} or @samp{both} + Traditional AIX shared library versioning (versioned @code{Shared Object} + files as members of unversioned @code{Archive Library} files named diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index de40f62e219..f735557aed0 100644 +index 792ce283bb9..cedffc51987 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -707,7 +707,8 @@ Objective-C and Objective-C++ Dialects}. +@@ -254,7 +254,8 @@ in the following sections. + -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare + -Wdeprecated-copy -Wdeprecated-copy-dtor + -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion +--Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base ++-Weffc++ -Wno-elaborated-enum-base ++-Wno-exceptions -Wextra-semi -Wno-inaccessible-base + -Wno-inherited-variadic-ctor -Wno-init-list-lifetime + -Winvalid-constexpr -Winvalid-imported-macros + -Wno-invalid-offsetof -Wno-literal-suffix +@@ -706,8 +707,9 @@ Objective-C and Objective-C++ Dialects}. + -freg-struct-return -fshort-enums -fshort-wchar -fverbose-asm -fpack-struct[=@var{n}] -fleading-underscore -ftls-model=@var{model} - -fstack-reuse=@var{reuse_level} +--fstack-reuse=@var{reuse_level} --ftrampolines -ftrapv -fwrapv -+-fstack-use-cumulative-args -+-ftrampolines -foff-stack-trampolines -ftrapv -fwrapv ++-fstack-reuse=@var{reuse_level} -fstack-use-cumulative-args ++-ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} ++-ftrapv -fwrapv -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} -fstrict-volatile-bitfields -fsync-libcalls} -@@ -18160,6 +18161,17 @@ the behavior of older compilers in which temporaries' stack space is +@@ -914,7 +916,7 @@ Objective-C and Objective-C++ Dialects}. + -iframework + -image_base -init -install_name -keep_private_externs + -multi_module -multiply_defined -multiply_defined_unused +--noall_load -no_dead_strip_inits_and_terms ++-noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths + -nofixprebinding -nomultidefs -noprebind -noseglinkedit + -pagezero_size -prebind -prebind_all_twolevel_modules + -private_bundle -read_only_relocs -sectalign +@@ -927,7 +929,7 @@ Objective-C and Objective-C++ Dialects}. + -twolevel_namespace -umbrella -undefined + -unexported_symbols_list -weak_reference_mismatches + -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} +--mkernel -mone-byte-bool} ++-mkernel -mone-byte-bool -munreachable-traps} + + @emph{DEC Alpha Options} + @gccoptlist{-mno-fp-regs -msoft-float +@@ -3839,6 +3841,15 @@ bool b = e <= 3.7; + @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled + by @option{-Wenum-conversion}. + ++@opindex Welaborated-enum-base ++@opindex Wno-elaborated-enum-base ++@item -Wno-elaborated-enum-base ++For C++11 and above, warn if an (invalid) additional enum-base is used ++in an elaborated-type-specifier. That is, if an enum with given ++underlying type and no enumerator list is used in a declaration other ++than just a standalone declaration of the enum. Enabled by default. This ++warning is upgraded to an error with -pedantic-errors. ++ + @opindex Winit-list-lifetime + @opindex Wno-init-list-lifetime + @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} +@@ -4802,7 +4813,7 @@ Use @var{class-name} as the name of the class to instantiate for each + literal string specified with the syntax @code{@@"@dots{}"}. The default + class name is @code{NXConstantString} if the GNU runtime is being used, and + @code{NSConstantString} if the NeXT runtime is being used (see below). On +-Darwin (macOS, MacOS X) platforms, the @option{-fconstant-cfstrings} option, if ++Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if + also present, overrides the @option{-fconstant-string-class} setting and cause + @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings. + Note that @option{-fconstant-cfstrings} is an alias for the target-specific +@@ -4816,7 +4827,7 @@ runtime. This is the default for most types of systems. + @opindex fnext-runtime + @item -fnext-runtime + Generate output compatible with the NeXT runtime. This is the default +-for NeXT-based systems, including Darwin and Mac OS X@. The macro ++for NeXT-based systems, including Darwin / macOS. The macro + @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is + used. + +@@ -6031,8 +6042,45 @@ Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) + requires a diagnostic, in some cases where there is undefined behavior + at compile-time and in some other cases that do not prevent compilation + of programs that are valid according to the standard. This is not +-equivalent to @option{-Werror=pedantic}, since there are errors enabled +-by this option and not enabled by the latter and vice versa. ++equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be ++useful, as it only makes errors of the diagnostics that are controlled by ++@option{-Wpedantic}, whereas this option also affects required diagnostics that ++are always enabled or controlled by options other than @option{-Wpedantic}. ++ ++If you want the required diagnostics that are warnings by default to ++be errors instead, but don't also want to enable the @option{-Wpedantic} ++diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic} ++(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but ++only as warnings). ++ ++Some required diagnostics are errors by default, but can be reduced to ++warnings using @option{-fpermissive} or their specific warning option, ++e.g. @option{-Wno-error=narrowing}. ++ ++Some diagnostics for non-ISO practices are controlled by specific ++warning options other than @option{-Wpedantic}, but are also made ++errors by @option{-pedantic-errors}. For instance: ++ ++@gccoptlist{ ++-Wattributes @r{(for standard attributes)} ++-Wchanges-meaning @r{(C++)} ++-Wcomma-subscript @r{(C++23 or later)} ++-Wdeclaration-after-statement @r{(C90 or earlier)} ++-Welaborated-enum-base @r{(C++11 or later)} ++-Wimplicit-int @r{(C99 or later)} ++-Wimplicit-function-declaration @r{(C99 or later)} ++-Wincompatible-pointer-types ++-Wint-conversion ++-Wlong-long @r{(C90 or earlier)} ++-Wmain ++-Wnarrowing @r{(C++11 or later)} ++-Wpointer-arith ++-Wpointer-sign ++-Wincompatible-pointer-types ++-Wregister @r{(C++17 or later)} ++-Wvla @r{(C90 or earlier)} ++-Wwrite-strings @r{(C++11 or later)} ++} + + @opindex Wall + @opindex Wno-all +@@ -11285,7 +11333,7 @@ possible. + Produce debugging information in DWARF format (if that is supported). + The value of @var{version} may be either 2, 3, 4 or 5; the default + version for most targets is 5 (with the exception of VxWorks, TPF and +-Darwin/Mac OS X, which default to version 2, and AIX, which defaults ++Darwin / macOS, which default to version 2, and AIX, which defaults + to version 4). + + Note that with DWARF Version 2, some ports require and always +@@ -18167,6 +18215,17 @@ the behavior of older compilers in which temporaries' stack space is not reused, the aggressive stack reuse can lead to runtime errors. This option is used to control the temporary stack reuse optimization. @@ -4199,31 +6900,92 @@ index de40f62e219..f735557aed0 100644 @opindex ftrapv @item -ftrapv This option generates traps for signed overflow on addition, subtraction, -@@ -18218,6 +18230,19 @@ instructions. It does not allow exceptions to be thrown from - arbitrary signal handlers such as @code{SIGALRM}. This enables - @option{-fexceptions}. - -+@opindex foff-stack-trampolines -+@item -foff-stack-trampolines -+Certain platforms (such as the Apple M1) do not permit an executable -+stack. Generate calls to @code{__builtin_nested_func_ptr_created} and -+@code{__builtin_nested_func_ptr_deleted} in order to allocate and -+deallocate trampoline space on the executable heap. Please note that -+these functions are implemented in libgcc, and will not be compiled in -+unless you provide @option{--enable-off-stack-trampolines} when -+building gcc. @emph{PLEASE NOTE}: The trampolines are @emph{not} -+guaranteed to be correctly deallocated if you @code{setjmp}, -+instantiate nested functions, and then @code{longjmp} back to a state -+prior to having allocated those nested functions. -+ - @opindex fdelete-dead-exceptions - @item -fdelete-dead-exceptions - Consider that instructions that may throw exceptions but don't otherwise +@@ -18652,6 +18711,20 @@ For languages other than Ada, the @code{-ftrampolines} and + trampolines are always generated on platforms that need them + for nested functions. + ++@opindex ftrampoline-impl ++@item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} ++By default, trampolines are generated on stack. However, certain platforms ++(such as the Apple M1) do not permit an executable stack. Compiling with ++@option{-ftrampoline-impl=heap} generate calls to ++@code{__gcc_nested_func_ptr_created} and ++@code{__gcc_nested_func_ptr_deleted} in order to allocate and ++deallocate trampoline space on the executable heap. These functions are ++implemented in libgcc, and will only be provided on specific targets: ++x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap ++trampolines are @emph{not} guaranteed to be correctly deallocated if you ++@code{setjmp}, instantiate nested functions, and then @code{longjmp} back ++to a state prior to having allocated those nested functions. ++ + @opindex fvisibility + @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} + Set the default ELF image symbol visibility to the specified option---all +@@ -24024,6 +24097,11 @@ without that switch. Using this switch may require recompiling all + other modules in a program, including system libraries. Use this + switch to conform to a non-default data model. + ++@opindex munreachable-traps ++@item -munreachable-traps ++Causes @code{__builtin_unreachable} to be rendered as a trap. This is the ++default for all Darwin architectures. ++ + @opindex mfix-and-continue + @opindex ffix-and-continue + @opindex findirect-data +@@ -24070,6 +24148,14 @@ an executable when linking, using the Darwin @file{libtool} command. + This causes GCC's output file to have the @samp{ALL} subtype, instead of + one controlled by the @option{-mcpu} or @option{-march} option. + ++@opindex nodefaultrpaths ++@item -nodefaultrpaths ++Do not add default run paths for the compiler library directories to ++executables, modules or dynamic libraries. On macOS 10.5 and later, ++the embedded runpath is added by default unless the user adds ++@option{-nodefaultrpaths} to the link line. Run paths are needed ++(and therefore enforced) to build on macOS version 10.11 or later. ++ + @item -allowable_client @var{client_name} + @itemx -client_name + @itemx -compatibility_version +@@ -29823,7 +29909,7 @@ the same as @option{-mbig}. + + @opindex mdynamic-no-pic + @item -mdynamic-no-pic +-On Darwin and Mac OS X systems, compile code so that it is not ++On Darwin / macOS systems, compile code so that it is not + relocatable, but that its external references are relocatable. The + resulting code is suitable for applications, but not shared + libraries. +diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi +index 26df8b490df..f9a23180ed8 100644 +--- a/gcc/doc/plugins.texi ++++ b/gcc/doc/plugins.texi +@@ -44,7 +44,7 @@ Plugins are loaded with + + Where @var{name} is the plugin name and @var{ext} is the platform-specific + dynamic library extension. It should be @code{dll} on Windows/MinGW, +-@code{dylib} on Darwin/Mac OS X, and @code{so} on all other platforms. ++@code{dylib} on Darwin/macOS, and @code{so} on all other platforms. + The plugin arguments are parsed by GCC and passed to respective + plugins as key-value pairs. Multiple plugins can be invoked by + specifying multiple @option{-fplugin} arguments. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi -index a660e33739b..4479f8cbf0e 100644 +index a660e33739b..1080f85dfa1 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi -@@ -4354,6 +4354,16 @@ with the specified mode and type. The default hook returns +@@ -1042,6 +1042,10 @@ also define the hook to @code{default_promote_function_mode_always_promote} + if you would like to apply the same rules given by @code{PROMOTE_MODE}. + @end deftypefn + ++@deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE_CA (cumulative_args_t, @var{function_arg_info}, @var{const_tree}, int *@var{}, @var{int}) ++Like @code{promote_function_mode}, but takes a cumulative_args pointer and a current arg to supply the input. ++@end deftypefn ++ + @defmac PARM_BOUNDARY + Normal alignment required for function parameters on the stack, in + bits. All stack parameters receive at least this much alignment +@@ -4354,6 +4358,16 @@ with the specified mode and type. The default hook returns @code{PARM_BOUNDARY} for all arguments. @end deftypefn @@ -4240,7 +7002,7 @@ index a660e33739b..4479f8cbf0e 100644 @deftypefn {Target Hook} {unsigned int} TARGET_FUNCTION_ARG_ROUND_BOUNDARY (machine_mode @var{mode}, const_tree @var{type}) Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY}, which is the default value for this hook. You can define this hook to -@@ -4361,6 +4371,16 @@ return a different value if an argument size must be rounded to a larger +@@ -4361,6 +4375,16 @@ return a different value if an argument size must be rounded to a larger value. @end deftypefn @@ -4257,11 +7019,41 @@ index a660e33739b..4479f8cbf0e 100644 @defmac FUNCTION_ARG_REGNO_P (@var{regno}) A C expression that is nonzero if @var{regno} is the number of a hard register in which function arguments are sometimes passed. This does +@@ -5764,7 +5788,7 @@ This hook determines whether a function from a class of functions + Set this macro to 1 to use the "NeXT" Objective-C message sending conventions + by default. This calling convention involves passing the object, the selector + and the method arguments all at once to the method-lookup library function. +-This is the usual setting when targeting Darwin/Mac OS X systems, which have ++This is the usual setting when targeting Darwin / macOS systems, which have + the NeXT runtime installed. + + If the macro is set to 0, the "GNU" Objective-C message sending convention +@@ -12365,6 +12389,11 @@ This target hook can be used to generate a target-specific code + If selftests are enabled, run any selftests for this target. + @end deftypefn + ++@deftypefn {Target Hook} bool TARGET_UNREACHABLE_SHOULD_TRAP (void) ++This hook should return @code{true} if the target wants @code{__builtin_unreachable} to expand to a trap or @code{abort ()}. ++ The default value is false. ++@end deftypefn ++ + @deftypefn {Target Hook} bool TARGET_MEMTAG_CAN_TAG_ADDRESSES () + True if the backend architecture naturally supports ignoring some region + of pointers. This feature means that @option{-fsanitize=hwaddress} can diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in -index f7ab5d48a63..cf6259c6cf6 100644 +index f7ab5d48a63..7f82c02bf33 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in -@@ -3341,8 +3341,12 @@ required. +@@ -938,6 +938,8 @@ applied. + + @hook TARGET_PROMOTE_FUNCTION_MODE + ++@hook TARGET_PROMOTE_FUNCTION_MODE_CA ++ + @defmac PARM_BOUNDARY + Normal alignment required for function parameters on the stack, in + bits. All stack parameters receive at least this much alignment +@@ -3341,8 +3343,12 @@ required. @hook TARGET_FUNCTION_ARG_BOUNDARY @@ -4274,10 +7066,182 @@ index f7ab5d48a63..cf6259c6cf6 100644 @defmac FUNCTION_ARG_REGNO_P (@var{regno}) A C expression that is nonzero if @var{regno} is the number of a hard register in which function arguments are sometimes passed. This does +@@ -4008,7 +4014,7 @@ macro, a reasonable default is used. + Set this macro to 1 to use the "NeXT" Objective-C message sending conventions + by default. This calling convention involves passing the object, the selector + and the method arguments all at once to the method-lookup library function. +-This is the usual setting when targeting Darwin/Mac OS X systems, which have ++This is the usual setting when targeting Darwin / macOS systems, which have + the NeXT runtime installed. + + If the macro is set to 0, the "GNU" Objective-C message sending convention +@@ -7965,6 +7971,8 @@ maintainer is familiar with. + + @hook TARGET_RUN_TARGET_SELFTESTS + ++@hook TARGET_UNREACHABLE_SHOULD_TRAP ++ + @hook TARGET_MEMTAG_CAN_TAG_ADDRESSES + + @hook TARGET_MEMTAG_TAG_SIZE +diff --git a/gcc/exec-tool.in b/gcc/exec-tool.in +index bddf46ab70a..a9120f36e19 100644 +--- a/gcc/exec-tool.in ++++ b/gcc/exec-tool.in +@@ -23,6 +23,8 @@ ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@" + ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@" + ORIGINAL_LD_BFD_FOR_TARGET="@ORIGINAL_LD_BFD_FOR_TARGET@" + ORIGINAL_LD_GOLD_FOR_TARGET="@ORIGINAL_LD_GOLD_FOR_TARGET@" ++ORIGINAL_LLD_FOR_TARGET="@ORIGINAL_LLD_FOR_TARGET@" ++ORIGINAL_CLASSIC_LD_FOR_TARGET="@ORIGINAL_CLASSIC_LD_FOR_TARGET@" + ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@" + ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@" + ORIGINAL_DSYMUTIL_FOR_TARGET="@ORIGINAL_DSYMUTIL_FOR_TARGET@" +@@ -39,24 +41,41 @@ case "$invoked" in + dir=gas + ;; + collect-ld) +- # Check -fuse-ld=bfd and -fuse-ld=gold +- case " $* " in +- *\ -fuse-ld=bfd\ *) +- original=$ORIGINAL_LD_BFD_FOR_TARGET +- ;; +- *\ -fuse-ld=gold\ *) +- original=$ORIGINAL_LD_GOLD_FOR_TARGET +- ;; +- *) +- # when using a linker plugin, gcc will always pass '-plugin' as the +- # first or second option to the linker. +- if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then +- original=$ORIGINAL_PLUGIN_LD_FOR_TARGET +- else +- original=$ORIGINAL_LD_FOR_TARGET +- fi +- ;; +- esac ++ # when using a linker plugin, gcc will always pass '-plugin' as the ++ # first or second option to the linker. ++ if test x"$1" = "x-plugin" || test x"$2" = "x-plugin"; then ++ original=$ORIGINAL_PLUGIN_LD_FOR_TARGET ++ else ++ original=$ORIGINAL_LD_FOR_TARGET ++ fi ++ # Check -fuse-ld=bfd, -fuse-ld=gold and -fuse-ld=classic ++ # Remove -fuse-ld=classic from the command line ++ for arg do ++ # temporarily, remove the arg. ++ shift ++ case $arg in ++ -fuse-ld=bfd) ++ original=$ORIGINAL_LD_BFD_FOR_TARGET ++ ;; ++ -fuse-ld=gold) ++ original=$ORIGINAL_LD_GOLD_FOR_TARGET ++ ;; ++ -fuse-ld=lld) ++ original=$ORIGINAL_LLD_FOR_TARGET ++ # We want to remove this from the command line; by the slightly ++ # obtuse mechanism of not putting it back. ++ continue ++ ;; ++ -fuse-ld=classic) ++ original=$ORIGINAL_CLASSIC_LD_FOR_TARGET ++ # As for lld. ++ continue ++ ;; ++ *) ;; ++ esac ++ # if we want to keep the arg, put it back. ++ set -- "$@" "$arg" ++ done + prog=ld-new$exeext + if test "$original" = ../gold/ld-new$exeext; then + dir=gold +diff --git a/gcc/explow.cc b/gcc/explow.cc +index 6424c0802f0..7c2973a9602 100644 +--- a/gcc/explow.cc ++++ b/gcc/explow.cc +@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see + #include "langhooks.h" + #include "except.h" + #include "dojump.h" ++#include "calls.h" + #include "explow.h" + #include "expr.h" + #include "stringpool.h" +@@ -817,6 +818,16 @@ promote_function_mode (const_tree type, machine_mode mode, int *punsignedp, + return mode; + } + } ++ ++machine_mode ++promote_function_mode (cumulative_args_t args_so_far, function_arg_info arg, ++ const_tree funtype, int *punsignedp , int for_return) ++{ ++ return targetm.calls.promote_function_mode_ca (args_so_far, arg, funtype, ++ punsignedp, for_return); ++// return promote_function_mode (arg.type, arg.mode, punsignedp, funtype, for_return); ++} ++ + /* Return the mode to use to store a scalar of TYPE and MODE. + PUNSIGNEDP points to the signedness of the type and may be adjusted + to show what signedness to use on extension operations. */ +diff --git a/gcc/explow.h b/gcc/explow.h +index 2db4f5c0de0..c7d22862187 100644 +--- a/gcc/explow.h ++++ b/gcc/explow.h +@@ -20,6 +20,8 @@ along with GCC; see the file COPYING3. If not see + #ifndef GCC_EXPLOW_H + #define GCC_EXPLOW_H + ++#include "calls.h" /* for cummulative args stuff. */ ++ + /* Return a memory reference like MEMREF, but which is known to have a + valid address. */ + extern rtx validize_mem (rtx); +@@ -47,8 +49,13 @@ extern rtx force_not_mem (rtx); + + /* Return mode and signedness to use when an argument or result in the + given mode is promoted. */ +-extern machine_mode promote_function_mode (const_tree, machine_mode, int *, +- const_tree, int); ++machine_mode promote_function_mode (const_tree, machine_mode, int *, ++ const_tree, int); ++ ++/* Return mode and signedness to use when an argument or result in the ++ given mode is promoted. */ ++machine_mode promote_function_mode (cumulative_args_t, function_arg_info, ++ const_tree, int *, int); + + /* Return mode and signedness to use when an object in the given mode + is promoted. */ +diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi +index 87baf5ac9a1..908f2b7a344 100644 +--- a/gcc/fortran/gfortran.texi ++++ b/gcc/fortran/gfortran.texi +@@ -978,7 +978,7 @@ low level file descriptor corresponding to an open Fortran unit. Then, + using e.g. the @code{ISO_C_BINDING} feature, one can call the + underlying system call to flush dirty data to stable storage, such as + @code{fsync} on POSIX, @code{_commit} on MingW, or @code{fcntl(fd, +-F_FULLSYNC, 0)} on Mac OS X. The following example shows how to call ++F_FULLSYNC, 0)} on macOS. The following example shows how to call + fsync: + + @smallexample diff --git a/gcc/function.cc b/gcc/function.cc -index edf0b2ec6cf..a8d49aa7613 100644 +index 8d6c4478866..4308e24b5cb 100644 --- a/gcc/function.cc +++ b/gcc/function.cc +@@ -58,8 +58,8 @@ along with GCC; see the file COPYING3. If not see + #include "varasm.h" + #include "except.h" + #include "dojump.h" +-#include "explow.h" + #include "calls.h" ++#include "explow.h" + #include "expr.h" + #include "optabs-tree.h" + #include "output.h" @@ -2448,7 +2448,10 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm, else if (DECL_CHAIN (parm)) data->arg.named = 1; /* Not the last non-variadic parm. */ @@ -4290,7 +7254,23 @@ index edf0b2ec6cf..a8d49aa7613 100644 else data->arg.named = 0; /* Treat as variadic. */ -@@ -2505,6 +2508,7 @@ assign_parms_setup_varargs (struct assign_parm_data_all *all, +@@ -2490,9 +2493,12 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm, + + /* Find mode as it is passed by the ABI. */ + unsignedp = TYPE_UNSIGNED (data->arg.type); +- data->arg.mode +- = promote_function_mode (data->arg.type, data->arg.mode, &unsignedp, +- TREE_TYPE (current_function_decl), 0); ++// data->arg.mode ++// = promote_function_mode (data->arg.type, data->arg.mode, &unsignedp, ++// TREE_TYPE (current_function_decl), 0); ++ data->arg.mode = promote_function_mode (all->args_so_far, data->arg, ++ TREE_TYPE (current_function_decl), ++ &unsignedp, 0); + } + + /* A subroutine of assign_parms. Invoke setup_incoming_varargs. */ +@@ -2505,6 +2511,7 @@ assign_parms_setup_varargs (struct assign_parm_data_all *all, function_arg_info last_named_arg = data->arg; last_named_arg.named = true; @@ -4298,7 +7278,7 @@ index edf0b2ec6cf..a8d49aa7613 100644 targetm.calls.setup_incoming_varargs (all->args_so_far, last_named_arg, &varargs_pretend_bytes, no_rtl); -@@ -2613,7 +2617,9 @@ assign_parm_find_entry_rtl (struct assign_parm_data_all *all, +@@ -2613,7 +2620,9 @@ assign_parm_find_entry_rtl (struct assign_parm_data_all *all, locate_and_pad_parm (data->arg.mode, data->arg.type, in_regs, all->reg_parm_stack_space, @@ -4309,7 +7289,7 @@ index edf0b2ec6cf..a8d49aa7613 100644 &all->stack_args_size, &data->locate); /* Update parm_stack_boundary if this parameter is passed in the -@@ -3944,7 +3950,8 @@ gimplify_parameters (gimple_seq *cleanup) +@@ -3945,7 +3954,8 @@ gimplify_parameters (gimple_seq *cleanup) if (data.arg.pass_by_reference) { tree type = TREE_TYPE (data.arg.type); @@ -4319,7 +7299,7 @@ index edf0b2ec6cf..a8d49aa7613 100644 if (reference_callee_copied (&all.args_so_far_v, orig_arg)) { tree local, t; -@@ -4047,6 +4054,7 @@ gimplify_parameters (gimple_seq *cleanup) +@@ -4048,6 +4058,7 @@ gimplify_parameters (gimple_seq *cleanup) void locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs, int reg_parm_stack_space, int partial, @@ -4327,7 +7307,7 @@ index edf0b2ec6cf..a8d49aa7613 100644 tree fndecl ATTRIBUTE_UNUSED, struct args_size *initial_offset_ptr, struct locate_and_pad_arg_data *locate) -@@ -4084,9 +4092,23 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs, +@@ -4085,9 +4096,23 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs, ? arg_size_in_bytes (type) : size_int (GET_MODE_SIZE (passed_mode))); where_pad = targetm.calls.function_arg_padding (passed_mode, type); @@ -4470,10 +7450,10 @@ index 12ceef39180..af071079940 100644 #endif } max_align_t; diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in -index a65f13853ae..3fd564a5932 100644 +index 55079209264..5bdba6c6a4c 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in -@@ -59,7 +59,7 @@ LIBGCCJIT_AGE = 1 +@@ -69,7 +69,7 @@ LIBGCCJIT_COMPAT = 0 LIBGCCJIT_BASENAME = libgccjit LIBGCCJIT_SONAME = \ @@ -4482,11 +7462,38 @@ index a65f13853ae..3fd564a5932 100644 LIBGCCJIT_FILENAME = $(LIBGCCJIT_BASENAME).$(LIBGCCJIT_VERSION_NUM).dylib LIBGCCJIT_LINKER_NAME = $(LIBGCCJIT_BASENAME).dylib +diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc +index e06f161aad9..2a04573b47a 100644 +--- a/gcc/jit/jit-playback.cc ++++ b/gcc/jit/jit-playback.cc +@@ -3024,7 +3024,7 @@ invoke_driver (const char *ctxt_progname, + ADD_ARG ("-fno-use-linker-plugin"); + + #if defined (DARWIN_X86) || defined (DARWIN_PPC) +- /* OS X's linker defaults to treating undefined symbols as errors. ++ /* macOS's linker defaults to treating undefined symbols as errors. + If the context has any imported functions or globals they will be + undefined until the .so is dynamically-linked into the process. + Ensure that the driver passes in "-undefined dynamic_lookup" to the +diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h +index 057d3e58e73..04545e4c6f6 100644 +--- a/gcc/jit/libgccjit.h ++++ b/gcc/jit/libgccjit.h +@@ -21,6 +21,9 @@ along with GCC; see the file COPYING3. If not see + #define LIBGCCJIT_H + + #include ++#ifdef __APPLE__ ++# include /* For ssize_t. */ ++#endif + + #ifdef __cplusplus + extern "C" { diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in -index b34db0d9156..e6ad91ee168 100644 +index 0ae3e183977..320f9300e5f 100644 --- a/gcc/m2/Make-lang.in +++ b/gcc/m2/Make-lang.in -@@ -478,6 +478,11 @@ GM2_MIN_FLAGS=$(GM2_G) $(GM2_OS) \ +@@ -501,6 +501,11 @@ GM2_MIN_FLAGS=$(GM2_G) $(GM2_OS) \ -Wpedantic-cast -Wpedantic-param-names -fno-exceptions \ -ffunction-sections -fdata-sections $(GM2_CPP) @@ -4498,17 +7505,7 @@ index b34db0d9156..e6ad91ee168 100644 O2=-O2 -g SO_O2=-O2 -g -fPIC SO=-O0 -g -fPIC -@@ -1354,23 +1359,23 @@ m2/boot-bin/mc$(exeext): $(BUILD-MC-BOOT-O) $(BUILD-MC-INTERFACE-O) \ - - m2/mc-boot/$(SRC_PREFIX)%.o: m2/mc-boot/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@ -+ $(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/m2/mc-boot-ch -I$(srcdir)/m2/mc-boot -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) $< -o $@ - - m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) $(CXXFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ -+ $(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ +@@ -1396,7 +1401,7 @@ m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.c m2/gm2-libs/gm2-l m2/mc-boot-ch/$(SRC_PREFIX)%.o: m2/mc-boot-ch/$(SRC_PREFIX)%.cc m2/gm2-libs/gm2-libs-host.h -test -d $(@D) || $(mkinstalldirs) $(@D) @@ -4516,146 +7513,176 @@ index b34db0d9156..e6ad91ee168 100644 + $(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -DHAVE_CONFIG_H -g -c -I. -Im2/gm2-libs -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) -Im2/gm2-libs $< -o $@ m2/mc-boot/main.o: $(M2LINK) $(srcdir)/m2/init/mcinit - -test -d $(@D) || $(mkinstalldirs) $(@D) - unset CC ; $(M2LINK) -s --langc++ --exit --name m2/mc-boot/main.cc $(srcdir)/m2/init/mcinit -- $(CXX) $(CXXFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@ -+ $(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) -g -c -I. -I$(srcdir)/../include -I$(srcdir) $(INCLUDES) m2/mc-boot/main.cc -o $@ - - mcflex.o: mcflex.c m2/gm2-libs/gm2-libs-host.h -- $(CC) $(CFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc -+ $(CC) $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2/mc -g -c $< -o $@ # remember that mcReserved.h is copied into m2/mc - - mcflex.c: $(srcdir)/m2/mc/mc.flex - flex -t $< > $@ -@@ -1378,17 +1383,17 @@ mcflex.c: $(srcdir)/m2/mc/mc.flex - m2/gm2-libs-boot/M2RTS.o: $(srcdir)/m2/gm2-libs/M2RTS.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(MC) --suppress-noreturn -o=m2/gm2-libs-boot/M2RTS.c $(srcdir)/m2/gm2-libs/M2RTS.mod -- $(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@ -+ $(COMPILER) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/M2RTS.c -o $@ - - m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs-boot/%.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs-boot/$*.mod -- $(COMPILER) -c -DIN_GCC $(CFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@ -+ $(COMPILER) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) $(MCINCLUDES) m2/gm2-libs-boot/$*.c -o $@ - - m2/gm2-libs-boot/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(MC) -o=m2/gm2-libs-boot/$*.c $(srcdir)/m2/gm2-libs/$*.mod -- $(COMPILER) -c -DIN_GCC $(CFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@ -+ $(COMPILER) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) m2/gm2-libs-boot/$*.c -o $@ - - m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS) - -test -d $(@D) || $(mkinstalldirs) $(@D) -@@ -1396,49 +1401,49 @@ m2/gm2-libs-boot/$(SRC_PREFIX)%.h: $(srcdir)/m2/gm2-libs/%.def $(MCDEPS) - - m2/gm2-libs-boot/RTcodummy.o: $(srcdir)/m2/gm2-libs-ch/RTcodummy.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/RTintdummy.o: $(srcdir)/m2/gm2-libs-ch/RTintdummy.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/wrapc.o: $(srcdir)/m2/gm2-libs-ch/wrapc.c m2/gm2-libs-boot/$(SRC_PREFIX)wrapc.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@ -+ $(CXX) -c -DHAVE_CONFIG_H $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libs $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/UnixArgs.o: $(srcdir)/m2/gm2-libs-ch/UnixArgs.cc m2/gm2-libs-boot/$(SRC_PREFIX)UnixArgs.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c -DIN_GCC $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c -DIN_GCC $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/errno.o: $(srcdir)/m2/gm2-libs-ch/errno.c m2/gm2-libs-boot/$(SRC_PREFIX)errno.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/dtoa.o: $(srcdir)/m2/gm2-libs-ch/dtoa.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/ldtoa.o: $(srcdir)/m2/gm2-libs-ch/ldtoa.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/termios.o: $(srcdir)/m2/gm2-libs-ch/termios.c $(BUILD-LIBS-BOOT-H) m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/SysExceptions.o: $(srcdir)/m2/gm2-libs-ch/SysExceptions.c \ - m2/gm2-libs-boot/$(SRC_PREFIX)SysExceptions.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-boot/SysStorage.o: $(srcdir)/m2/gm2-libs/SysStorage.mod $(MCDEPS) $(BUILD-BOOT-H) - -test -d $(@D) || $(mkinstalldirs) $(@D) - $(MC) -o=m2/gm2-libs-boot/SysStorage.c $(srcdir)/m2/gm2-libs/SysStorage.mod -- $(COMPILER) -DIN_GCC -c $(CFLAGS) \ -+ $(COMPILER) -DIN_GCC -c $(CFLAGS) $(GM2_PICFLAGS) \ - -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(MCINCLUDES) $(INCLUDES) \ - m2/gm2-libs-boot/SysStorage.c -o m2/gm2-libs-boot/SysStorage.o - -@@ -1511,7 +1516,7 @@ m2/gm2-compiler/%.o: m2/gm2-compiler/%.mod - - m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -DBUILD_GM2_LIBS_TARGET -DBUILD_GM2_LIBS -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ - - m2/gm2-libs-iso/%.o: $(srcdir)/m2/gm2-libs-iso/%.mod - -test -d $(@D) || $(mkinstalldirs) $(@D) -@@ -1613,15 +1618,15 @@ m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs/%.mod $(MCDEPS) $(BUILD-BOOT-H) + -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR) +diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc +index fe2d2b595b4..85580592803 100644 +--- a/gcc/objc/objc-act.cc ++++ b/gcc/objc/objc-act.cc +@@ -3317,7 +3317,7 @@ objc_build_string_object (tree string) + length = TREE_STRING_LENGTH (string) - 1; + + /* The target may have different ideas on how to construct an ObjC string +- literal. On Darwin (Mac OS X), for example, we may wish to obtain a ++ literal. On Darwin / macOS, for example, we may wish to obtain a + constant CFString reference instead. + At present, this is only supported for the NeXT runtime. */ + if (flag_next_runtime +@@ -10362,5 +10362,51 @@ objc_common_tree_size (enum tree_code code) + } + } - m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.c m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -DBUILD_GM2_LIBS -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ ++/* Information for Objective-C-specific features known to __has_feature. */ ++ ++struct objc_feature_info ++{ ++ typedef bool (*predicate_t) (); ++ ++ const char *ident; ++ predicate_t predicate; ++ ++ constexpr objc_feature_info (const char *name) ++ : ident (name), predicate (nullptr) {} ++ constexpr objc_feature_info (const char *name, predicate_t p) ++ : ident (name), predicate (p) {} ++ ++ bool has_feature () const ++ { ++ return predicate ? predicate () : true; ++ } ++}; ++ ++static bool objc_nonfragile_abi_p () ++{ ++ return flag_next_runtime && flag_objc_abi >= 2; ++} ++ ++static constexpr objc_feature_info objc_features[] = ++{ ++ { "objc_default_synthesize_properties" }, ++ { "objc_instancetype" }, ++ { "objc_nonfragile_abi", objc_nonfragile_abi_p } ++}; ++ ++/* Register Objective-C-specific features for __has_feature. */ ++ ++void ++objc_common_register_features () ++{ ++ for (unsigned i = 0; i < ARRAY_SIZE (objc_features); i++) ++ { ++ const objc_feature_info *info = objc_features + i; ++ if (!info->has_feature ()) ++ continue; ++ ++ c_common_register_feature (info->ident, true); ++ } ++} - m2/gm2-libs/%.o: $(srcdir)/m2/gm2-libs-ch/%.cc m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot $(INCLUDES) $< -o $@ + #include "gt-objc-objc-act.h" +diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h +index e21ab52d8ca..bcf0249515a 100644 +--- a/gcc/objc/objc-act.h ++++ b/gcc/objc/objc-act.h +@@ -29,6 +29,9 @@ int objc_gimplify_expr (tree *, gimple_seq *, gimple_seq *); + void objc_common_init_ts (void); + const char *objc_get_sarif_source_language (const char *); + ++/* Register features common to Objective-C and Objective-C++. */ ++void objc_common_register_features (); ++ + /* NB: The remaining public functions are prototyped in c-common.h, for the + benefit of stub-objc.cc and objc-act.cc. */ + +diff --git a/gcc/objc/objc-lang.cc b/gcc/objc/objc-lang.cc +index 89b3be48b9e..7568248ba13 100644 +--- a/gcc/objc/objc-lang.cc ++++ b/gcc/objc/objc-lang.cc +@@ -58,6 +58,16 @@ objc_get_sarif_source_language (const char *) + return "objectivec"; + } - m2/gm2-libs/choosetemp.o: m2/gm2-libs-ch/choosetemp.c m2/gm2-libiberty/Gchoosetemp.h m2/gm2-libs/gm2-libs-host.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) -c $(CFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ -+ $(CXX) -c $(CFLAGS) $(GM2_PICFLAGS) -Im2/gm2-libs -I$(srcdir)/m2 -Im2 -I. -Im2/gm2-libs-boot -Im2/gm2-libiberty -I$(srcdir)/m2/gm2-libiberty/ $(INCLUDES) $< -o $@ ++/* Implement c-family hook to add language-specific features ++ for __has_{feature,extension}. */ ++ ++void ++c_family_register_lang_features () ++{ ++ objc_common_register_features (); ++ c_register_features (); ++} ++ + /* Lang hook routines common to C and ObjC appear in c-objc-common.cc; + there should be very few (if any) routines below. */ - m2/gm2-libs-boot/libgm2.a: m2/boot-bin/mc$(exeext) $(BUILD-LIBS-BOOT) - -test -d $(@D) || $(mkinstalldirs) $(@D) -@@ -1722,11 +1727,11 @@ include m2/Make-maintainer - else - m2/pge-boot/%.o: m2/pge-boot/%.c m2/gm2-libs/gm2-libs-host.h m2/gm2config.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) $(CFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ -+ $(CXX) $(CFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ +diff --git a/gcc/objcp/objcp-lang.cc b/gcc/objcp/objcp-lang.cc +index 9887209b9c8..ede59a69d13 100644 +--- a/gcc/objcp/objcp-lang.cc ++++ b/gcc/objcp/objcp-lang.cc +@@ -80,6 +80,16 @@ objcp_tsubst_copy_and_build (tree t, tree args, tsubst_flags_t complain, + #undef RECURSE + } - m2/pge-boot/%.o: m2/pge-boot/%.cc m2/gm2-libs/gm2-libs-host.h m2/gm2config.h - -test -d $(@D) || $(mkinstalldirs) $(@D) -- $(CXX) $(CXXFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ -+ $(CXX) $(CXXFLAGS) $(GM2_PICFLAGS) $(INCLUDES) -I$(srcdir)/m2/pge-boot -Im2/gm2-libs -g -c $< -o $@ ++/* Implement c-family hook to add language-specific features ++ for __has_{feature,extension}. */ ++ ++void ++c_family_register_lang_features () ++{ ++ objc_common_register_features (); ++ cp_register_features (); ++} ++ + static void + objcxx_init_ts (void) + { +diff --git a/gcc/opts.cc b/gcc/opts.cc +index e0ba89ffe51..71371e23cf1 100644 +--- a/gcc/opts.cc ++++ b/gcc/opts.cc +@@ -3215,6 +3215,7 @@ common_handle_option (struct gcc_options *opts, + break; - $(PGE): $(BUILD-PGE-O) - +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(BUILD-PGE-O) -lm + case OPT_fuse_ld_bfd: ++ case OPT_fuse_ld_classic: + case OPT_fuse_ld_gold: + case OPT_fuse_ld_lld: + case OPT_fuse_ld_mold: +diff --git a/gcc/plugin.cc b/gcc/plugin.cc +index 142f3fa4131..c3e40b2cf75 100644 +--- a/gcc/plugin.cc ++++ b/gcc/plugin.cc +@@ -190,10 +190,10 @@ add_new_plugin (const char* plugin_name) + #if defined(__MINGW32__) + static const char plugin_ext[] = ".dll"; + #elif defined(__APPLE__) +- /* Mac OS has two types of libraries: dynamic libraries (.dylib) and ++ /* macOS has two types of libraries: dynamic libraries (.dylib) and + plugins (.bundle). Both can be used with dlopen()/dlsym() but the + former cannot be linked at build time (i.e., with the -lfoo linker +- option). A GCC plugin is therefore probably a Mac OS plugin but their ++ option). A GCC plugin is therefore probably a macOS plugin but their + use seems to be quite rare and the .bundle extension is more of a + recommendation rather than the rule. This raises the questions of how + well they are supported by tools (e.g., libtool). So to avoid diff --git a/gcc/target.def b/gcc/target.def -index 171bbd1caf1..ba2c342d40f 100644 +index 171bbd1caf1..75b51d26074 100644 --- a/gcc/target.def +++ b/gcc/target.def -@@ -4992,6 +4992,18 @@ with the specified mode and type. The default hook returns\n\ +@@ -4574,6 +4574,13 @@ if you would like to apply the same rules given by @code{PROMOTE_MODE}.", + const_tree funtype, int for_return), + default_promote_function_mode) + ++DEFHOOK ++(promote_function_mode_ca, ++ "Like @code{promote_function_mode}, but takes a cumulative_args pointer \ ++ and a current arg to supply the input.", ++ machine_mode, (cumulative_args_t, function_arg_info, const_tree, int *, int), ++ default_promote_function_mode_ca) ++ + DEFHOOK + (promote_prototypes, + "This target hook returns @code{true} if an argument declared in a\n\ +@@ -4992,6 +4999,18 @@ with the specified mode and type. The default hook returns\n\ unsigned int, (machine_mode mode, const_tree type), default_function_arg_boundary) @@ -4674,7 +7701,7 @@ index 171bbd1caf1..ba2c342d40f 100644 DEFHOOK (function_arg_round_boundary, "Normally, the size of an argument is rounded up to @code{PARM_BOUNDARY},\n\ -@@ -5001,6 +5013,18 @@ value.", +@@ -5001,6 +5020,18 @@ value.", unsigned int, (machine_mode mode, const_tree type), default_function_arg_round_boundary) @@ -4693,6 +7720,23 @@ index 171bbd1caf1..ba2c342d40f 100644 /* Return the diagnostic message string if function without a prototype is not allowed for this 'val' argument; NULL otherwise. */ DEFHOOK +@@ -7138,6 +7169,16 @@ DEFHOOKPOD + @option{-fsanitize=shadow-call-stack}. The default value is false.", + bool, false) + ++/* This value represents whether __builtin_unreachable should be expanded ++ as a trap instruction (or an abort() if the trap is not available). */ ++DEFHOOK ++(unreachable_should_trap, ++ "This hook should return @code{true} if the target wants \ ++ @code{__builtin_unreachable} to expand to a trap or @code{abort ()}.\n\ ++ The default value is false.", ++ bool, (void), ++ hook_bool_void_false) ++ + /* Close the 'struct gcc_target' definition. */ + HOOK_VECTOR_END (C90_EMPTY_HACK) + diff --git a/gcc/target.h b/gcc/target.h index cd448e4b7ab..064523f2a2e 100644 --- a/gcc/target.h @@ -4723,10 +7767,26 @@ index cd448e4b7ab..064523f2a2e 100644 /* Types of memory operation understood by the "by_pieces" infrastructure. Used by the TARGET_USE_BY_PIECES_INFRASTRUCTURE_P target hook and diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc -index 51bf3fb7a82..421aacd829d 100644 +index 51bf3fb7a82..13a7c206cc5 100644 --- a/gcc/targhooks.cc +++ b/gcc/targhooks.cc -@@ -856,6 +856,14 @@ default_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED, +@@ -159,6 +159,15 @@ default_promote_function_mode_always_promote (const_tree type, + return promote_mode (type, mode, punsignedp); + } + ++machine_mode ++default_promote_function_mode_ca (cumulative_args_t, function_arg_info arg, ++ const_tree funtype, int *punsignedp, ++ int for_return) ++{ ++ return promote_function_mode (arg.type, arg.mode, punsignedp, ++ funtype, for_return); ++} ++ + machine_mode + default_cc_modes_compatible (machine_mode m1, machine_mode m2) + { +@@ -856,6 +865,14 @@ default_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED, return PARM_BOUNDARY; } @@ -4741,7 +7801,7 @@ index 51bf3fb7a82..421aacd829d 100644 unsigned int default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED, const_tree type ATTRIBUTE_UNUSED) -@@ -863,6 +871,14 @@ default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED, +@@ -863,6 +880,14 @@ default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED, return PARM_BOUNDARY; } @@ -4757,10 +7817,20 @@ index 51bf3fb7a82..421aacd829d 100644 hook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED) { diff --git a/gcc/targhooks.h b/gcc/targhooks.h -index cf3d3107a0d..cd3c6a8d18a 100644 +index cf3d3107a0d..cd4e830b2f3 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h -@@ -158,6 +158,12 @@ extern unsigned int default_function_arg_boundary (machine_mode, +@@ -34,6 +34,9 @@ extern machine_mode default_promote_function_mode (const_tree, machine_mode, + extern machine_mode default_promote_function_mode_always_promote + (const_tree, machine_mode, int *, const_tree, int); + ++extern machine_mode default_promote_function_mode_ca ++ (cumulative_args_t, function_arg_info, const_tree, int *, int); ++ + extern machine_mode default_cc_modes_compatible (machine_mode, + machine_mode); + +@@ -158,6 +161,12 @@ extern unsigned int default_function_arg_boundary (machine_mode, const_tree); extern unsigned int default_function_arg_round_boundary (machine_mode, const_tree); @@ -4773,199 +7843,8 @@ index cf3d3107a0d..cd3c6a8d18a 100644 extern bool hook_bool_const_rtx_commutative_p (const_rtx, int); extern rtx default_function_value (const_tree, const_tree, bool); extern HARD_REG_SET default_zero_call_used_regs (HARD_REG_SET); -diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp -index d232be2fa90..fb233e3d082 100644 ---- a/gcc/testsuite/gfortran.dg/coarray/caf.exp -+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp -@@ -28,6 +28,7 @@ - - # Load procedures from common libraries. - load_lib gfortran-dg.exp -+load_lib atomic-dg.exp - - # If a testcase doesn't have special options, use these. - global DEFAULT_FFLAGS -@@ -47,6 +48,7 @@ global gfortran_test_path - global gfortran_aux_module_flags - set gfortran_test_path $srcdir/$subdir - set gfortran_aux_module_flags $DEFAULT_FFLAGS -+ - proc dg-compile-aux-modules { args } { - global gfortran_test_path - global gfortran_aux_module_flags -@@ -71,7 +73,16 @@ proc dg-compile-aux-modules { args } { - # Add -latomic only where supported. Assume built-in support elsewhere. - set maybe_atomic_lib "" - if [check_effective_target_libatomic_available] { -- set maybe_atomic_lib "-latomic" -+ #set maybe_atomic_lib "-latomic" -+ if ![is_remote host] { -+ if [info exists TOOL_OPTIONS] { -+ set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]" -+ } else { -+ set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]" -+ } -+ } -+ set t [get_multilibs] -+ puts "maybe al $maybe_atomic_lib ml $t" - } - - # Main loop. -@@ -97,14 +108,14 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]] - foreach flags $option_list { - verbose "Testing $nshort (single), $flags" 1 - set gfortran_aux_module_flags "-fcoarray=single $flags" -- dg-test $test "-fcoarray=single $flags $maybe_atomic_lib" "" -+ dg-test $test "-fcoarray=single $flags" $maybe_atomic_lib - cleanup-modules "" - } - - foreach flags $option_list { - verbose "Testing $nshort (libcaf_single), $flags" 1 - set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_single" -- dg-test $test "-fcoarray=lib $flags -lcaf_single $maybe_atomic_lib" "" -+ dg-test $test "-fcoarray=lib $flags -lcaf_single" $maybe_atomic_lib - cleanup-modules "" - } - } -diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp -index ee2760327dc..73541ea7301 100644 ---- a/gcc/testsuite/gfortran.dg/dg.exp -+++ b/gcc/testsuite/gfortran.dg/dg.exp -@@ -18,6 +18,7 @@ - - # Load support procs. - load_lib gfortran-dg.exp -+load_lib atomic-dg.exp - - # If a testcase doesn't have special options, use these. - global DEFAULT_FFLAGS -@@ -53,13 +54,38 @@ proc dg-compile-aux-modules { args } { - } - } - -+# coarray tests might need libatomic. Assume that it is either not needed or -+# provided by builtins if it's not available. -+set maybe_atomic_lib "" -+if [check_effective_target_libatomic_available] { -+ if ![is_remote host] { -+ if [info exists TOOL_OPTIONS] { -+ set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]" -+ } else { -+ set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]" -+ } -+ } else { -+ set maybe_atomic_lib "" -+ } -+ set t [get_multilibs] -+ puts "dg set al $maybe_atomic_lib ml $t" -+} -+ -+set all_flags $DEFAULT_FFLAGS -+if { $maybe_atomic_lib != "" } { -+ foreach f $maybe_atomic_lib { -+ lappend all_flags $f -+ } -+} -+ -+puts "revised FFLAGS $all_flags" -+ - # Main loop. - gfortran-dg-runtest [lsort \ -- [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS -+ [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $all_flags - - gfortran-dg-runtest [lsort \ -- [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $DEFAULT_FFLAGS -- -+ [glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $all_flags - - # All done. - dg-finish -diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp -index 35e60eaaed5..157b60908d6 100644 ---- a/gcc/testsuite/lib/asan-dg.exp -+++ b/gcc/testsuite/lib/asan-dg.exp -@@ -78,7 +78,7 @@ proc asan_link_flags_1 { paths lib } { - || [file exists "${gccpath}/libsanitizer/${lib}/.libs/lib${lib}.${shlib_ext}"] } { - append flags " -B${gccpath}/libsanitizer/ " - append flags " -B${gccpath}/libsanitizer/${lib}/ " -- append flags " -L${gccpath}/libsanitizer/${lib}/.libs " -+ append flags " -B${gccpath}/libsanitizer/${lib}/.libs " - append ld_library_path ":${gccpath}/libsanitizer/${lib}/.libs" - } - } else { -diff --git a/gcc/testsuite/lib/atomic-dg.exp b/gcc/testsuite/lib/atomic-dg.exp -index 1589acd8eaf..ce1799cef2d 100644 ---- a/gcc/testsuite/lib/atomic-dg.exp -+++ b/gcc/testsuite/lib/atomic-dg.exp -@@ -33,7 +33,7 @@ proc atomic_link_flags { paths } { - if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"] - || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } { - append flags " -B${gccpath}/libatomic/ " -- append flags " -L${gccpath}/libatomic/.libs" -+ append flags " -B${gccpath}/libatomic/.libs" - append ld_library_path ":${gccpath}/libatomic/.libs" - } - } else { -diff --git a/gcc/testsuite/lib/target-libpath.exp b/gcc/testsuite/lib/target-libpath.exp -index 6d530fb4af6..5de039b4fc2 100644 ---- a/gcc/testsuite/lib/target-libpath.exp -+++ b/gcc/testsuite/lib/target-libpath.exp -@@ -67,6 +67,7 @@ proc set_ld_library_path_env_vars { } { - global orig_dyld_library_path - global orig_path - global orig_gcc_exec_prefix -+ global ENABLE_DARWIN_AT_RPATH - global env - - # Save the original GCC_EXEC_PREFIX. -@@ -133,6 +134,7 @@ proc set_ld_library_path_env_vars { } { - # - # Doing this is somewhat of a hack as ld_library_path gets repeated in - # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables. -+ if { ![istarget *-*-darwin*] } { - if { $orig_ld_library_path_saved } { - setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path" - } else { -@@ -166,11 +168,23 @@ proc set_ld_library_path_env_vars { } { - } else { - setenv LD_LIBRARY_PATH_64 "$ld_library_path" - } -- if { $orig_dyld_library_path_saved } { -- setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path" -- } else { -- setenv DYLD_LIBRARY_PATH "$ld_library_path" - } -+ if { [istarget *-*-darwin*] } { -+ if { [info exists ENABLE_DARWIN_AT_RPATH] || [istarget *-*-darwin1\[5-9\]*] -+ || [istarget *-*-darwin20*] } { -+ # Either we are not using DYLD_LIBRARY_PATH or we're on a version of the -+ # OS for which it is not passed through system exes. -+ if [info exists env(DYLD_LIBRARY_PATH)] { -+ unsetenv DYLD_LIBRARY_PATH -+ } -+ } else { -+ if { $orig_dyld_library_path_saved } { -+ setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path" -+ } else { -+ setenv DYLD_LIBRARY_PATH "$ld_library_path" -+ } -+ } -+ } - if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } { - if { $orig_path_saved } { - setenv PATH "$ld_library_path:$orig_path" -@@ -179,6 +193,7 @@ proc set_ld_library_path_env_vars { } { - } - } - -+ verbose -log "set paths" - verbose -log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]" - verbose -log "LD_RUN_PATH=[getenv LD_RUN_PATH]" - verbose -log "SHLIB_PATH=[getenv SHLIB_PATH]" diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc -index 1418e1f7f56..060072ba76e 100644 +index 0f44b3dc735..8355425f0d1 100644 --- a/gcc/tree-nested.cc +++ b/gcc/tree-nested.cc @@ -611,6 +611,14 @@ get_trampoline_type (struct nesting_info *info) @@ -4974,7 +7853,7 @@ index 1418e1f7f56..060072ba76e 100644 + /* When trampolines are created off-stack then the only thing we need in the + local frame is a single pointer. */ -+ if (flag_off_stack_trampolines) ++ if (flag_trampoline_impl == TRAMPOLINE_IMPL_HEAP) + { + trampoline_type = build_pointer_type (void_type_node); + return trampoline_type; @@ -4983,7 +7862,7 @@ index 1418e1f7f56..060072ba76e 100644 align = TRAMPOLINE_ALIGNMENT; size = TRAMPOLINE_SIZE; -@@ -2788,17 +2796,27 @@ convert_tramp_reference_op (tree *tp, int *walk_subtrees, void *data) +@@ -2793,17 +2801,27 @@ convert_tramp_reference_op (tree *tp, int *walk_subtrees, void *data) /* Compute the address of the field holding the trampoline. */ x = get_frame_field (info, target_context, x, &wi->gsi); @@ -4997,7 +7876,7 @@ index 1418e1f7f56..060072ba76e 100644 + /* APB: We don't need to do the adjustment calls when using off-stack + trampolines, any such adjustment will be done when the off-stack + trampoline is created. */ -+ if (!descr && flag_off_stack_trampolines) ++ if (!descr && flag_trampoline_impl == TRAMPOLINE_IMPL_HEAP) + x = gsi_gimplify_val (info, x, &wi->gsi); else - builtin = builtin_decl_implicit (BUILT_IN_ADJUST_TRAMPOLINE); @@ -5020,7 +7899,7 @@ index 1418e1f7f56..060072ba76e 100644 /* Cast back to the proper function type. */ x = build1 (NOP_EXPR, TREE_TYPE (t), x); -@@ -3377,6 +3395,7 @@ build_init_call_stmt (struct nesting_info *info, tree decl, tree field, +@@ -3382,6 +3400,7 @@ build_init_call_stmt (struct nesting_info *info, tree decl, tree field, static void finalize_nesting_tree_1 (struct nesting_info *root) { @@ -5028,14 +7907,14 @@ index 1418e1f7f56..060072ba76e 100644 gimple_seq stmt_list = NULL; gimple *stmt; tree context = root->context; -@@ -3508,9 +3527,48 @@ finalize_nesting_tree_1 (struct nesting_info *root) +@@ -3513,9 +3532,48 @@ finalize_nesting_tree_1 (struct nesting_info *root) if (!field) continue; - x = builtin_decl_implicit (BUILT_IN_INIT_TRAMPOLINE); - stmt = build_init_call_stmt (root, i->context, field, x); - gimple_seq_add_stmt (&stmt_list, stmt); -+ if (flag_off_stack_trampolines) ++ if (flag_trampoline_impl == TRAMPOLINE_IMPL_HEAP) + { + /* We pass a whole bunch of arguments to the builtin function that + creates the off-stack trampoline, these are @@ -5060,13 +7939,13 @@ index 1418e1f7f56..060072ba76e 100644 + root->frame_decl, field, NULL_TREE); + arg3 = build_addr (x); + -+ x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_CREATED); ++ x = builtin_decl_explicit (BUILT_IN_GCC_NESTED_PTR_CREATED); + stmt = gimple_build_call (x, 3, arg1, arg2, arg3); + gimple_seq_add_stmt (&stmt_list, stmt); + + /* This call to delete the nested function trampoline is added to + the cleanup list, and called when we exit the current scope. */ -+ x = builtin_decl_implicit (BUILT_IN_NESTED_PTR_DELETED); ++ x = builtin_decl_explicit (BUILT_IN_GCC_NESTED_PTR_DELETED); + stmt = gimple_build_call (x, 0); + gimple_seq_add_stmt (&cleanup_list, stmt); + } @@ -5080,7 +7959,7 @@ index 1418e1f7f56..060072ba76e 100644 } } -@@ -3535,11 +3593,40 @@ finalize_nesting_tree_1 (struct nesting_info *root) +@@ -3540,11 +3598,40 @@ finalize_nesting_tree_1 (struct nesting_info *root) /* If we created initialization statements, insert them. */ if (stmt_list) { @@ -5089,9 +7968,9 @@ index 1418e1f7f56..060072ba76e 100644 - bind = gimple_seq_first_stmt_as_a_bind (gimple_body (context)); - gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind)); - gimple_bind_set_body (bind, stmt_list); -+ if (flag_off_stack_trampolines) ++ if (flag_trampoline_impl == TRAMPOLINE_IMPL_HEAP) + { -+ /* Handle the new, off stack trampolines. */ ++ /* Handle off-stack trampolines. */ + gbind *bind; + annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context)); + annotate_all_with_location (cleanup_list, DECL_SOURCE_LOCATION (context)); @@ -5102,7 +7981,7 @@ index 1418e1f7f56..060072ba76e 100644 + + if (cleanup_list != NULL) + { -+ /* We Maybe shouldn't be creating this try/finally if -fno-exceptions is ++ /* Maybe we shouldn't be creating this try/finally if -fno-exceptions is + in use. If this is the case, then maybe we should, instead, be + inserting the cleanup code onto every path out of this function? Not + yet figured out how we would do this. */ @@ -5127,47 +8006,38 @@ index 1418e1f7f56..060072ba76e 100644 /* If a chain_decl was created, then it needs to be registered with diff --git a/gcc/tree.cc b/gcc/tree.cc -index 207293c48cb..0a4770ec801 100644 +index 12dea81a5f3..88370418be4 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc -@@ -9852,6 +9852,23 @@ build_common_builtin_nodes (void) +@@ -9853,6 +9853,28 @@ build_common_builtin_nodes (void) "__builtin_nonlocal_goto", ECF_NORETURN | ECF_NOTHROW); + tree ptr_ptr_type_node = build_pointer_type (ptr_type_node); + -+ ftype = build_function_type_list (void_type_node, -+ ptr_type_node, // void *chain -+ ptr_type_node, // void *func -+ ptr_ptr_type_node, // void **dst -+ NULL_TREE); -+ local_define_builtin ("__builtin_nested_func_ptr_created", ftype, -+ BUILT_IN_NESTED_PTR_CREATED, -+ "__builtin_nested_func_ptr_created", ECF_NOTHROW); -+ -+ ftype = build_function_type_list (void_type_node, -+ NULL_TREE); -+ local_define_builtin ("__builtin_nested_func_ptr_deleted", ftype, -+ BUILT_IN_NESTED_PTR_DELETED, -+ "__builtin_nested_func_ptr_deleted", ECF_NOTHROW); ++ if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_CREATED)) ++ { ++ ftype = build_function_type_list (void_type_node, ++ ptr_type_node, // void *chain ++ ptr_type_node, // void *func ++ ptr_ptr_type_node, // void **dst ++ NULL_TREE); ++ local_define_builtin ("__builtin___gcc_nested_func_ptr_created", ftype, ++ BUILT_IN_GCC_NESTED_PTR_CREATED, ++ "__gcc_nested_func_ptr_created", ECF_NOTHROW); ++ } ++ ++ if (!builtin_decl_explicit_p (BUILT_IN_GCC_NESTED_PTR_DELETED)) ++ { ++ ftype = build_function_type_list (void_type_node, NULL_TREE); ++ local_define_builtin ("__builtin___gcc_nested_func_ptr_deleted", ftype, ++ BUILT_IN_GCC_NESTED_PTR_DELETED, ++ "__gcc_nested_func_ptr_deleted", ECF_NOTHROW); ++ } + ftype = build_function_type_list (void_type_node, ptr_type_node, ptr_type_node, NULL_TREE); local_define_builtin ("__builtin_setjmp_setup", ftype, -diff --git a/gotools/Makefile.in b/gotools/Makefile.in -index 2783b91ef4b..9739a79526b 100644 ---- a/gotools/Makefile.in -+++ b/gotools/Makefile.in -@@ -704,8 +704,8 @@ distclean-generic: - maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." --@NATIVE_FALSE@install-exec-local: - @NATIVE_FALSE@uninstall-local: -+@NATIVE_FALSE@install-exec-local: - clean: clean-am - - clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \ diff --git a/intl/Makefile.in b/intl/Makefile.in index 409d693c48e..5beebdc152c 100644 --- a/intl/Makefile.in @@ -5277,7 +8147,7 @@ index 16a740aa230..81aa831f59f 100644 AC_CONFIG_FILES(Makefile config.intl) diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am -index c6c8d81c56a..d18738cd7e6 100644 +index c6c8d81c56a..3bb32f32ebf 100644 --- a/libatomic/Makefile.am +++ b/libatomic/Makefile.am @@ -65,8 +65,13 @@ libatomic_version_script = @@ -5291,12 +8161,12 @@ index c6c8d81c56a..d18738cd7e6 100644 -libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) $(lt_host_flags) +libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \ -+ $(lt_host_flags) $(libatomic_darwin_rpath) ++ $(lt_host_flags) $(libatomic_darwin_rpath) libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \ fenv.c fence.c flag.c diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in -index a0fa3dfc8cc..155c9aa9255 100644 +index a0fa3dfc8cc..ef7ef451751 100644 --- a/libatomic/Makefile.in +++ b/libatomic/Makefile.in @@ -417,7 +417,12 @@ noinst_LTLIBRARIES = libatomic_convenience.la @@ -5308,13 +8178,13 @@ index a0fa3dfc8cc..155c9aa9255 100644 +@ENABLE_DARWIN_AT_RPATH_TRUE@ -Wc,-nodefaultrpaths \ +@ENABLE_DARWIN_AT_RPATH_TRUE@ -Wl,-rpath,@loader_path +libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \ -+ $(lt_host_flags) $(libatomic_darwin_rpath) ++ $(lt_host_flags) $(libatomic_darwin_rpath) + libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c \ init.c fenv.c fence.c flag.c $(am__append_2) SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas diff --git a/libatomic/configure b/libatomic/configure -index e47d2d7fb35..7c687b932e7 100755 +index e47d2d7fb35..7c1d46b6762 100755 --- a/libatomic/configure +++ b/libatomic/configure @@ -658,6 +658,8 @@ OPT_LDFLAGS @@ -5334,16 +8204,17 @@ index e47d2d7fb35..7c687b932e7 100755 enable_maintainer_mode enable_symvers enable_werror -@@ -1452,6 +1455,8 @@ Optional Features: +@@ -1452,6 +1455,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer -@@ -7608,7 +7613,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -7608,7 +7614,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -5352,7 +8223,7 @@ index e47d2d7fb35..7c687b932e7 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9581,6 +9586,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9581,6 +9587,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -5402,7 +8273,7 @@ index e47d2d7fb35..7c687b932e7 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9598,9 +9646,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9598,9 +9647,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -5418,25 +8289,25 @@ index e47d2d7fb35..7c687b932e7 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -11406,7 +11458,7 @@ else +@@ -11406,7 +11459,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11409 "configure" -+#line 11461 "configure" ++#line 11462 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11512,7 +11564,7 @@ else +@@ -11512,7 +11565,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11515 "configure" -+#line 11567 "configure" ++#line 11568 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11797,6 +11849,15 @@ fi +@@ -11797,6 +11850,15 @@ fi @@ -5452,7 +8323,7 @@ index e47d2d7fb35..7c687b932e7 100755 # For libtool versioning info, format is CURRENT:REVISION:AGE libtool_VERSION=3:0:2 -@@ -15924,6 +15985,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then +@@ -15924,6 +15986,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -5476,30 +8347,8 @@ index 31304685dbd..20981f16f70 100644 # For libtool versioning info, format is CURRENT:REVISION:AGE libtool_VERSION=3:0:2 AC_SUBST(libtool_VERSION) -diff --git a/libatomic/testsuite/lib/libatomic.exp b/libatomic/testsuite/lib/libatomic.exp -index 10f38475bc8..c6d645e9ae3 100644 ---- a/libatomic/testsuite/lib/libatomic.exp -+++ b/libatomic/testsuite/lib/libatomic.exp -@@ -148,11 +148,15 @@ proc libatomic_init { args } { - if { $blddir != "" } { - lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/" - lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}" -- lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs" -+ if [istarget *-*-darwin*] { -+ lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs" -+ } else { -+ lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs" -+ } - } - lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.." - -- if [istarget *-*-darwin*] { -+ if [istarget *-*-darwin\[89\]*] { - lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc" - } - diff --git a/libbacktrace/configure b/libbacktrace/configure -index 6af2c04c81a..38b54957034 100755 +index 6af2c04c81a..4a25e38a2dc 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -681,6 +681,8 @@ PIC_FLAG @@ -5519,16 +8368,17 @@ index 6af2c04c81a..38b54957034 100755 enable_largefile enable_cet enable_werror -@@ -1453,6 +1456,8 @@ Optional Features: +@@ -1453,6 +1456,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --disable-largefile omit support for large files --enable-cet enable Intel CET in target libraries [default=auto] --disable-werror disable building with -Werror -@@ -8010,7 +8015,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8010,7 +8016,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -5537,7 +8387,7 @@ index 6af2c04c81a..38b54957034 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9716,6 +9721,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9716,6 +9722,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -5587,7 +8437,7 @@ index 6af2c04c81a..38b54957034 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9733,9 +9781,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9733,9 +9782,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -5603,25 +8453,25 @@ index 6af2c04c81a..38b54957034 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -11541,7 +11593,7 @@ else +@@ -11541,7 +11594,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11544 "configure" -+#line 11596 "configure" ++#line 11597 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11647,7 +11699,7 @@ else +@@ -11647,7 +11700,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11650 "configure" -+#line 11702 "configure" ++#line 11703 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11886,6 +11938,15 @@ CC="$lt_save_CC" +@@ -11886,6 +11939,15 @@ CC="$lt_save_CC" @@ -5637,7 +8487,7 @@ index 6af2c04c81a..38b54957034 100755 # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; -@@ -14435,6 +14496,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then +@@ -14435,6 +14497,10 @@ if test -z "${HAVE_DWZ_TRUE}" && test -z "${HAVE_DWZ_FALSE}"; then as_fn_error $? "conditional \"HAVE_DWZ\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -5662,7 +8512,7 @@ index 39e6bf41e35..98b96fcb86f 100644 backtrace_supported=yes diff --git a/libcc1/configure b/libcc1/configure -index bae3b8712b6..9ee2b785eb1 100755 +index bae3b8712b6..cd9acc3bf13 100755 --- a/libcc1/configure +++ b/libcc1/configure @@ -787,6 +787,7 @@ with_pic @@ -5673,16 +8523,17 @@ index bae3b8712b6..9ee2b785eb1 100755 enable_cet with_gcc_major_version_only enable_werror_always -@@ -1439,6 +1440,8 @@ Optional Features: +@@ -1439,6 +1440,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-cet enable Intel CET in host libraries [default=auto] --enable-werror-always enable -Werror despite compiler version --enable-plugin enable plugin support -@@ -7271,7 +7274,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -7271,7 +7275,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -5691,7 +8542,7 @@ index bae3b8712b6..9ee2b785eb1 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -8976,6 +8979,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8976,6 +8980,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -5741,7 +8592,7 @@ index bae3b8712b6..9ee2b785eb1 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -8993,9 +9039,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8993,9 +9040,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -5757,25 +8608,25 @@ index bae3b8712b6..9ee2b785eb1 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -10801,7 +10851,7 @@ else +@@ -10801,7 +10852,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10804 "configure" -+#line 10854 "configure" ++#line 10855 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -10907,7 +10957,7 @@ else +@@ -10907,7 +10958,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10910 "configure" -+#line 10960 "configure" ++#line 10961 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12189,6 +12239,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -12189,6 +12240,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -5825,7 +8676,7 @@ index bae3b8712b6..9ee2b785eb1 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -12206,12 +12299,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -12206,12 +12300,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -6051,6 +8902,61 @@ index 89ac99b04bd..b29b4d6acf1 100644 AC_SUBST(PICFLAG) # Enable Intel CET on Intel CET enabled host if jit is enabled. +diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h +index b8e50ae15bb..26474a470ac 100644 +--- a/libcpp/include/cpplib.h ++++ b/libcpp/include/cpplib.h +@@ -756,6 +756,9 @@ struct cpp_callbacks + /* Callback to determine whether a built-in function is recognized. */ + int (*has_builtin) (cpp_reader *); + ++ /* Callback to determine whether a feature is available. */ ++ int (*has_feature) (cpp_reader *, bool); ++ + /* Callback that can change a user lazy into normal macro. */ + void (*user_lazy_macro) (cpp_reader *, cpp_macro *, unsigned); + +@@ -960,7 +963,9 @@ enum cpp_builtin_type + BT_HAS_STD_ATTRIBUTE, /* `__has_c_attribute(x)' */ + BT_HAS_BUILTIN, /* `__has_builtin(x)' */ + BT_HAS_INCLUDE, /* `__has_include(x)' */ +- BT_HAS_INCLUDE_NEXT /* `__has_include_next(x)' */ ++ BT_HAS_INCLUDE_NEXT, /* `__has_include_next(x)' */ ++ BT_HAS_FEATURE, /* `__has_feature(x)' */ ++ BT_HAS_EXTENSION /* `__has_extension(x)' */ + }; + + #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE)) +diff --git a/libcpp/init.cc b/libcpp/init.cc +index c508f06112a..465dafefe9d 100644 +--- a/libcpp/init.cc ++++ b/libcpp/init.cc +@@ -433,6 +433,8 @@ static const struct builtin_macro builtin_array[] = + B("__has_builtin", BT_HAS_BUILTIN, true), + B("__has_include", BT_HAS_INCLUDE, true), + B("__has_include_next",BT_HAS_INCLUDE_NEXT, true), ++ B("__has_feature", BT_HAS_FEATURE, true), ++ B("__has_extension", BT_HAS_EXTENSION, true), + /* Keep builtins not used for -traditional-cpp at the end, and + update init_builtins() if any more are added. */ + B("_Pragma", BT_PRAGMA, true), +diff --git a/libcpp/macro.cc b/libcpp/macro.cc +index d4238d4f621..d2e8f9bd411 100644 +--- a/libcpp/macro.cc ++++ b/libcpp/macro.cc +@@ -677,6 +677,12 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node, + number = builtin_has_include (pfile, node, + node->value.builtin == BT_HAS_INCLUDE_NEXT); + break; ++ ++ case BT_HAS_FEATURE: ++ case BT_HAS_EXTENSION: ++ number = pfile->cb.has_feature (pfile, ++ node->value.builtin == BT_HAS_FEATURE); ++ break; + } + + if (result == NULL) diff --git a/libdecnumber/configure b/libdecnumber/configure index fb6db05565a..84bc4ffc767 100755 --- a/libdecnumber/configure @@ -6171,7 +9077,7 @@ index 5524a6a571e..34e77a45d1a 100644 AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src AM_CCASFLAGS = $(AM_CPPFLAGS) $(CET_FLAGS) diff --git a/libffi/configure b/libffi/configure -index 2bb9f8d83d6..069476bc2e6 100755 +index 2bb9f8d83d6..0fae8b5c96d 100755 --- a/libffi/configure +++ b/libffi/configure @@ -667,6 +667,8 @@ MAINT @@ -6191,16 +9097,17 @@ index 2bb9f8d83d6..069476bc2e6 100755 enable_maintainer_mode enable_pax_emutramp enable_debug -@@ -1465,6 +1468,8 @@ Optional Features: +@@ -1465,6 +1468,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer -@@ -7797,7 +7802,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -7797,7 +7803,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -6209,7 +9116,7 @@ index 2bb9f8d83d6..069476bc2e6 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9771,6 +9776,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9771,6 +9777,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -6259,7 +9166,7 @@ index 2bb9f8d83d6..069476bc2e6 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9788,9 +9836,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9788,9 +9837,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -6275,25 +9182,25 @@ index 2bb9f8d83d6..069476bc2e6 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -11596,7 +11648,7 @@ else +@@ -11596,7 +11649,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11599 "configure" -+#line 11651 "configure" ++#line 11652 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11702,7 +11754,7 @@ else +@@ -11702,7 +11755,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11705 "configure" -+#line 11757 "configure" ++#line 11758 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12578,6 +12630,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -12578,6 +12631,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -6343,7 +9250,7 @@ index 2bb9f8d83d6..069476bc2e6 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -12595,12 +12690,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -12595,12 +12691,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -6367,7 +9274,7 @@ index 2bb9f8d83d6..069476bc2e6 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -14970,6 +15073,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +@@ -14970,6 +15074,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # Only expand once: @@ -6382,7 +9289,7 @@ index 2bb9f8d83d6..069476bc2e6 100755 if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}readelf", so it can be a program name with args. -@@ -17115,6 +17226,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then +@@ -17115,6 +17227,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -6405,37 +9312,19 @@ index 014d89d0423..716f20ae313 100644 AC_CHECK_TOOL(READELF, readelf) -diff --git a/libffi/testsuite/lib/libffi.exp b/libffi/testsuite/lib/libffi.exp -index 15d3d5ebd73..611f5177c7a 100644 ---- a/libffi/testsuite/lib/libffi.exp -+++ b/libffi/testsuite/lib/libffi.exp -@@ -337,8 +337,13 @@ proc libffi-init { args } { - verbose "libffi_dir $libffi_dir" - if { $libffi_dir != "" } { - set libffi_dir [file dirname ${libffi_dir}] -- set libffi_link_flags "-L${libffi_dir}/.libs" -- lappend libffi_link_flags "-L${blddircxx}/src/.libs" -+ if [istarget *-*-darwin*] { -+ set libffi_link_flags "-B${libffi_dir}/.libs" -+ lappend libffi_link_flags "-B${blddircxx}/src/.libs" -+ } else { -+ set libffi_link_flags "-L${libffi_dir}/.libs" -+ lappend libffi_link_flags "-L${blddircxx}/src/.libs" -+ } - } - - set_ld_library_path_env_vars -@@ -382,7 +387,7 @@ proc libffi_target_compile { source dest type options } { - # Darwin needs a stack execution allowed flag. - - if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"] -- || [istarget "*-*-darwin2*"] } { -+ || [istarget "x86_64-*-darwin2*"] } { - lappend options "additional_flags=-Wl,-allow_stack_execute" - lappend options "additional_flags=-Wl,-search_paths_first" - } +diff --git a/libffi/doc/version.texi b/libffi/doc/version.texi +index f2b741e87e4..6261b21fec9 100644 +--- a/libffi/doc/version.texi ++++ b/libffi/doc/version.texi +@@ -1,4 +1,4 @@ +-@set UPDATED 27 June 2021 +-@set UPDATED-MONTH June 2021 ++@set UPDATED 31 August 2022 ++@set UPDATED-MONTH August 2022 + @set EDITION 3.4.2 + @set VERSION 3.4.2 diff --git a/libgcc/config.host b/libgcc/config.host -index 9d7212028d0..018dfe79d82 100644 +index c94d69d84b7..c0a4cc6fa9b 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -82,7 +82,7 @@ m32c*-*-*) @@ -6447,7 +9336,21 @@ index 9d7212028d0..018dfe79d82 100644 cpu_type=aarch64 ;; alpha*-*-*) -@@ -251,7 +251,29 @@ case ${host} in +@@ -233,9 +233,11 @@ case ${host} in + ;; + esac + tmake_file="$tmake_file t-slibgcc-darwin" +- # newer toolsets produce warnings when building for unsupported versions. + case ${host} in +- *-*-darwin1[89]* | *-*-darwin2* ) ++ *-*-darwin2*) ++ tmake_file="t-darwin-min-11 $tmake_file" ++ ;; ++ *-*-darwin1[89]*) + tmake_file="t-darwin-min-8 $tmake_file" + ;; + *-*-darwin9* | *-*-darwin1[0-7]*) +@@ -251,7 +253,29 @@ case ${host} in echo "Warning: libgcc configured to support macOS 10.5" 1>&2 ;; esac @@ -6478,63 +9381,68 @@ index 9d7212028d0..018dfe79d82 100644 ;; *-*-dragonfly*) tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip" -@@ -395,6 +417,17 @@ aarch64*-*-elf | aarch64*-*-rtems*) +@@ -395,6 +419,15 @@ aarch64*-*-elf | aarch64*-*-rtems*) tmake_file="${tmake_file} t-dfprules" md_unwind_header=aarch64/aarch64-unwind.h ;; +aarch64*-*-darwin*) -+ extra_parts="$extra_parts crtfastmath.o" ++ extra_parts="$extra_parts crtfastmath.o libheapt_w.a" + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" + tmake_file="${tmake_file} ${cpu_type}/t-lse " + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp " + tmake_file="${tmake_file} t-crtfm t-dfprules" ++ tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline" + md_unwind_header=aarch64/aarch64-unwind.h -+ if test x$off_stack_trampolines = xyes; then -+ tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline" -+ fi + ;; aarch64*-*-freebsd*) extra_parts="$extra_parts crtfastmath.o" tmake_file="${tmake_file} ${cpu_type}/t-aarch64" -@@ -423,6 +456,9 @@ aarch64*-*-linux*) +@@ -423,6 +456,7 @@ aarch64*-*-linux*) tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" tmake_file="${tmake_file} t-dfprules" -+ if test x$off_stack_trampolines = xyes; then -+ tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline" -+ fi ++ tmake_file="${tmake_file} ${cpu_type}/t-heap-trampoline" ;; aarch64*-*-vxworks7*) extra_parts="$extra_parts crtfastmath.o" -@@ -691,12 +727,17 @@ hppa*-*-netbsd*) +@@ -691,12 +725,18 @@ hppa*-*-netbsd*) i[34567]86-*-darwin*) tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" tm_file="$tm_file i386/darwin-lib.h" +- extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" + extra_parts="$extra_parts libd10-uwfef.a " - extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" ++ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o" ++ extra_parts="$extra_parts crtfastmath.o libheapt_w.a" ++ tmake_file="${tmake_file} i386/t-heap-trampoline" ;; x86_64-*-darwin*) tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi" tm_file="$tm_file i386/darwin-lib.h" +- extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" + extra_parts="$extra_parts libd10-uwfef.a " - extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" -+ if test x$off_stack_trampolines = xyes; then -+ tmake_file="${tmake_file} i386/t-heap-trampoline" -+ fi ++ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o" ++ extra_parts="$extra_parts crtfastmath.o libheapt_w.a" ++ tmake_file="${tmake_file} i386/t-heap-trampoline" ;; i[34567]86-*-elfiamcu) tmake_file="$tmake_file i386/t-crtstuff t-softfp-sfdftf i386/32/t-softfp i386/32/t-iamcu i386/t-softfp t-softfp t-dfprules" -@@ -763,6 +804,9 @@ x86_64-*-linux*) +@@ -746,6 +786,7 @@ i[34567]86-*-linux*) tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules" tm_file="${tm_file} i386/elf-lib.h" md_unwind_header=i386/linux-unwind.h -+ if test x$off_stack_trampolines = xyes; then -+ tmake_file="${tmake_file} i386/t-heap-trampoline" -+ fi ++ tmake_file="${tmake_file} i386/t-heap-trampoline" + ;; + i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-kopensolaris*-gnu) + extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" +@@ -763,6 +804,7 @@ x86_64-*-linux*) + tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules" + tm_file="${tm_file} i386/elf-lib.h" + md_unwind_header=i386/linux-unwind.h ++ tmake_file="${tmake_file} i386/t-heap-trampoline" ;; x86_64-*-kfreebsd*-gnu) extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" -@@ -1171,12 +1215,14 @@ powerpc-*-darwin*) +@@ -1171,12 +1213,14 @@ powerpc-*-darwin*) # We build the darwin10 EH shim for Rosetta (running on x86 machines). tm_file="$tm_file i386/darwin-lib.h" tmake_file="$tmake_file rs6000/t-ppc64-fp rs6000/t-ibm-ldouble" @@ -6551,12 +9459,15 @@ index 9d7212028d0..018dfe79d82 100644 powerpc*-*-freebsd*) diff --git a/libgcc/config/aarch64/heap-trampoline.c b/libgcc/config/aarch64/heap-trampoline.c new file mode 100644 -index 00000000000..c8b83681ed7 +index 00000000000..b2c69aa5892 --- /dev/null +++ b/libgcc/config/aarch64/heap-trampoline.c -@@ -0,0 +1,172 @@ +@@ -0,0 +1,185 @@ +/* Copyright The GNU Toolchain Authors. */ + ++/* libc is required to allocate trampolines. */ ++#ifndef inhibit_libc ++ +#include +#include +#include @@ -6569,32 +9480,38 @@ index 00000000000..c8b83681ed7 +#include +#endif + ++/* HEAP_T_ATTR is provided to allow targets to build the exported functions ++ as weak definitions. */ ++#ifndef HEAP_T_ATTR ++# define HEAP_T_ATTR ++#endif ++ +void *allocate_trampoline_page (void); +int get_trampolines_per_page (void); +struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent); +void *allocate_trampoline_page (void); + -+void __builtin_nested_func_ptr_created (void *chain, void *func, void **dst); -+void __builtin_nested_func_ptr_deleted (void); -+ -+#if defined(__gnu_linux__) -+static const uint32_t aarch64_trampoline_insns[] = { -+ 0xd503245f, /* hint 34 */ -+ 0x580000b1, /* ldr x17, .+20 */ -+ 0x580000d2, /* ldr x18, .+24 */ -+ 0xd61f0220, /* br x17 */ -+ 0xd5033f9f, /* dsb sy */ -+ 0xd5033fdf /* isb */ ++void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst); ++void __gcc_nested_func_ptr_deleted (void); ++ ++#if defined(__linux__) ++static const unsigned char aarch64_trampoline_insns[6][4] = { ++ {0x5f, 0x24, 0x03, 0xd5}, /* hint 34 */ ++ {0xb1, 0x00, 0x00, 0x58}, /* ldr x17, .+20 */ ++ {0xd2, 0x00, 0x00, 0x58}, /* ldr x18, .+24 */ ++ {0x20, 0x02, 0x1f, 0xd6}, /* br x17 */ ++ {0x9f, 0x3f, 0x03, 0xd5}, /* dsb sy */ ++ {0xdf, 0x3f, 0x03, 0xd5} /* isb */ +}; + +#elif __APPLE__ -+static const uint32_t aarch64_trampoline_insns[] = { -+ 0xd503245f, /* hint 34 */ -+ 0x580000b1, /* ldr x17, .+20 */ -+ 0x580000d0, /* ldr x16, .+24 */ -+ 0xd61f0220, /* br x17 */ -+ 0xd5033f9f, /* dsb sy */ -+ 0xd5033fdf /* isb */ ++static const unsigned char aarch64_trampoline_insns[6][4] = { ++ {0x5f, 0x24, 0x03, 0xd5}, /* hint 34 */ ++ {0xb1, 0x00, 0x00, 0x58}, /* ldr x17, .+20 */ ++ {0xd0, 0x00, 0x00, 0x58}, /* ldr x16, .+24 */ ++ {0x20, 0x02, 0x1f, 0xd6}, /* br x17 */ ++ {0x9f, 0x3f, 0x03, 0xd5}, /* dsb sy */ ++ {0xdf, 0x3f, 0x03, 0xd5} /* isb */ +}; + +#else @@ -6602,7 +9519,7 @@ index 00000000000..c8b83681ed7 +#endif + +struct aarch64_trampoline { -+ uint32_t insns[6]; ++ unsigned char insns[6][4]; + void *func_ptr; + void *chain_ptr; +}; @@ -6630,7 +9547,7 @@ index 00000000000..c8b83681ed7 +{ + void *page; + -+#if defined(__gnu_linux__) ++#if defined(__linux__) + page = mmap (0, getpagesize (), PROT_WRITE | PROT_EXEC, + MAP_ANON | MAP_PRIVATE, 0, 0); +#elif __APPLE__ @@ -6661,8 +9578,9 @@ index 00000000000..c8b83681ed7 + return p; +} + ++HEAP_T_ATTR +void -+__builtin_nested_func_ptr_created (void *chain, void *func, void **dst) ++__gcc_nested_func_ptr_created (void *chain, void *func, void **dst) +{ + if (tramp_ctrl_curr == NULL) + { @@ -6708,8 +9626,9 @@ index 00000000000..c8b83681ed7 + *dst = &trampoline->insns; +} + ++HEAP_T_ATTR +void -+__builtin_nested_func_ptr_deleted (void) ++__gcc_nested_func_ptr_deleted (void) +{ + if (tramp_ctrl_curr == NULL) + abort (); @@ -6727,6 +9646,8 @@ index 00000000000..c8b83681ed7 + tramp_ctrl_curr = prev; + } +} ++ ++#endif /* !inhibit_libc */ diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S index dde3a28e07b..87ee33bc52a 100644 --- a/libgcc/config/aarch64/lse.S @@ -6828,7 +9749,7 @@ index 00000000000..f6ecda7b608 +BUILD_LIBGCCS1 = diff --git a/libgcc/config/aarch64/t-heap-trampoline b/libgcc/config/aarch64/t-heap-trampoline new file mode 100644 -index 00000000000..3f70c2cd0c0 +index 00000000000..6468fb8704f --- /dev/null +++ b/libgcc/config/aarch64/t-heap-trampoline @@ -0,0 +1,20 @@ @@ -6850,16 +9771,19 @@ index 00000000000..3f70c2cd0c0 +# along with GCC; see the file COPYING3. If not see +# . + -+LIB2ADD += $(srcdir)/config/aarch64/heap-trampoline.c -+HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=11.0 ++LIB2ADDEH += $(srcdir)/config/aarch64/heap-trampoline.c ++LIB2ADDEHSHARED += $(srcdir)/config/aarch64/heap-trampoline.c diff --git a/libgcc/config/i386/heap-trampoline.c b/libgcc/config/i386/heap-trampoline.c new file mode 100644 -index 00000000000..96e13bf828e +index 00000000000..2e8df1cfbd2 --- /dev/null +++ b/libgcc/config/i386/heap-trampoline.c -@@ -0,0 +1,172 @@ +@@ -0,0 +1,255 @@ +/* Copyright The GNU Toolchain Authors. */ + ++/* libc is required to allocate trampolines. */ ++#ifndef inhibit_libc ++ +#include +#include +#include @@ -6872,39 +9796,109 @@ index 00000000000..96e13bf828e +#include +#endif + ++/* HEAP_T_ATTR is provided to allow targets to build the exported functions ++ as weak definitions. */ ++#ifndef HEAP_T_ATTR ++# define HEAP_T_ATTR ++#endif ++ +void *allocate_trampoline_page (void); +int get_trampolines_per_page (void); +struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent); +void *allocate_trampoline_page (void); + -+void __builtin_nested_func_ptr_created (void *chain, void *func, void **dst); -+void __builtin_nested_func_ptr_deleted (void); ++void __gcc_nested_func_ptr_created (void *chain, void *func, void **dst); ++void __gcc_nested_func_ptr_deleted (void); ++ ++#if __x86_64__ + ++#ifdef __LP64__ +static const uint8_t trampoline_insns[] = { -+ /* movabs $,%r11 */ ++#if defined __CET__ && (__CET__ & 1) != 0 ++ /* endbr64. */ ++ 0xf3, 0x0f, 0x1e, 0xfa, ++#endif ++ ++ /* movabsq $,%r11 */ + 0x49, 0xbb, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + -+ /* movabs $,%r10 */ ++ /* movabsq $,%r10 */ + 0x49, 0xba, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* rex.WB jmpq *%r11 */ -+ 0x41, 0xff, 0xe3 ++ 0x41, 0xff, 0xe3, ++ ++ /* Pad to the multiple of 4 bytes. */ ++ 0x90 ++}; ++#else ++static const uint8_t trampoline_insns[] = { ++#if defined __CET__ && (__CET__ & 1) != 0 ++ /* endbr64. */ ++ 0xf3, 0x0f, 0x1e, 0xfa, ++#endif ++ ++ /* movl $,%r11d */ ++ 0x41, 0xbb, ++ 0x00, 0x00, 0x00, 0x00, ++ ++ /* movl $,%r10d */ ++ 0x41, 0xba, ++ 0x00, 0x00, 0x00, 0x00, ++ ++ /* rex.WB jmpq *%r11 */ ++ 0x41, 0xff, 0xe3, ++ ++ /* Pad to the multiple of 4 bytes. */ ++ 0x90 +}; ++#endif + +union ix86_trampoline { + uint8_t insns[sizeof(trampoline_insns)]; + + struct __attribute__((packed)) fields { ++#if defined __CET__ && (__CET__ & 1) != 0 ++ uint8_t endbr64[4]; ++#endif + uint8_t insn_0[2]; + void *func_ptr; + uint8_t insn_1[2]; + void *chain_ptr; + uint8_t insn_2[3]; ++ uint8_t pad; ++ } fields; ++}; ++ ++#elif __i386__ ++ ++static const uint8_t trampoline_insns[] = { ++ /* movl $,%ecx */ ++ 0xb9, ++ 0x00, 0x00, 0x00, 0x00, ++ ++ /* jmpl -. */ ++ 0xe9, ++ 0x00, 0x00, 0x00, 0x00, ++}; ++ ++union ix86_trampoline { ++ uint8_t insns[sizeof(trampoline_insns)]; ++ ++ struct __attribute__((packed)) fields { ++ uint8_t insn_0[1]; ++ void *chain_ptr; ++ uint8_t insn_1[1]; ++ uintptr_t func_offset; + } fields; +}; + ++#else ++#error unsupported architecture/ABI ++#endif ++ +struct tramp_ctrl_data +{ + struct tramp_ctrl_data *prev; @@ -6964,8 +9958,9 @@ index 00000000000..96e13bf828e + return p; +} + ++HEAP_T_ATTR +void -+__builtin_nested_func_ptr_created (void *chain, void *func, void **dst) ++__gcc_nested_func_ptr_created (void *chain, void *func, void **dst) +{ + if (tramp_ctrl_curr == NULL) + { @@ -6995,8 +9990,14 @@ index 00000000000..96e13bf828e + + memcpy (trampoline->insns, trampoline_insns, + sizeof(trampoline_insns)); -+ trampoline->fields.func_ptr = func; + trampoline->fields.chain_ptr = chain; ++#if __x86_64__ ++ trampoline->fields.func_ptr = func; ++#elif __i386__ ++ uintptr_t off_add = (uintptr_t) &trampoline->fields.func_offset; ++ off_add += 4; ++ trampoline->fields.func_offset = (uintptr_t)func - off_add; ++#endif + +#if __APPLE__ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400 + /* Re-enable write protection. */ @@ -7011,8 +10012,9 @@ index 00000000000..96e13bf828e + *dst = &trampoline->insns; +} + ++HEAP_T_ATTR +void -+__builtin_nested_func_ptr_deleted (void) ++__gcc_nested_func_ptr_deleted (void) +{ + if (tramp_ctrl_curr == NULL) + abort (); @@ -7030,9 +10032,11 @@ index 00000000000..96e13bf828e + tramp_ctrl_curr = prev; + } +} ++ ++#endif /* !inhibit_libc */ diff --git a/libgcc/config/i386/t-heap-trampoline b/libgcc/config/i386/t-heap-trampoline new file mode 100644 -index 00000000000..76f438d9529 +index 00000000000..5cd11f594ba --- /dev/null +++ b/libgcc/config/i386/t-heap-trampoline @@ -0,0 +1,20 @@ @@ -7054,8 +10058,40 @@ index 00000000000..76f438d9529 +# along with GCC; see the file COPYING3. If not see +# . + -+LIB2ADD += $(srcdir)/config/i386/heap-trampoline.c -+HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.8 ++LIB2ADDEH += $(srcdir)/config/i386/heap-trampoline.c ++LIB2ADDEHSHARED += $(srcdir)/config/i386/heap-trampoline.c +diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin +index a3bb70c6a0a..0f65b54a230 100644 +--- a/libgcc/config/t-darwin ++++ b/libgcc/config/t-darwin +@@ -51,5 +51,18 @@ LIB2ADDEH = $(srcdir)/unwind-dw2.c \ + # Do not build a shared unwind lib by default. + LIBEHSOBJS= + ++# Make heap trampoline helpers weak definitions so that we can merge them from ++# multiple DSOs. ++heap-trampoline.o: HOST_LIBGCC2_CFLAGS += \ ++ -DHEAP_T_ATTR='__attribute__((__weak__,__visibility__("default")))' ++heap-trampoline_s.o: HOST_LIBGCC2_CFLAGS += \ ++ -DHEAP_T_ATTR='__attribute__((__weak__,__visibility__("default")))' ++ ++# Make a heap trampoline support CRT so that it can be linked optionally, use ++# the shared version so that we can link with DSOs. ++libheapt_w.a: heap-trampoline_s.o ++ $(AR_CREATE_FOR_TARGET) $@ $< ++ $(RANLIB_FOR_TARGET) $@ ++ + # Symbols for all the sub-ports. + SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/libgcc-libsystem.ver +diff --git a/libgcc/config/t-darwin-min-11 b/libgcc/config/t-darwin-min-11 +new file mode 100644 +index 00000000000..4009d41addb +--- /dev/null ++++ b/libgcc/config/t-darwin-min-11 +@@ -0,0 +1,3 @@ ++# Support building with -mmacosx-version-min back to macOS 11. ++DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=11 ++DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=11 diff --git a/libgcc/config/t-darwin-rpath b/libgcc/config/t-darwin-rpath new file mode 100644 index 00000000000..e73d7f378b0 @@ -7146,183 +10182,36 @@ index cb0cbbdb1c5..da4886848e8 100644 done $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T* rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T* -diff --git a/libgcc/configure b/libgcc/configure -index be5d45f1755..85fc0b08c82 100755 ---- a/libgcc/configure -+++ b/libgcc/configure -@@ -630,7 +630,6 @@ LIPO - AR - toolexeclibdir - toolexecdir --enable_gcov - target_subdir - host_subdir - build_subdir -@@ -654,6 +653,8 @@ build_cpu - build - with_aix_soname - enable_vtable_verify -+enable_gcov -+off_stack_trampolines - enable_shared - libgcc_topdir - target_alias -@@ -701,6 +702,8 @@ with_target_subdir - with_cross_host - with_ld - enable_shared -+enable_off_stack_trampolines -+enable_gcov - enable_vtable_verify - with_aix_soname - enable_version_specific_runtime_libs -@@ -708,7 +711,6 @@ with_toolexeclibdir - with_slibdir - enable_maintainer_mode - with_build_libsubdir --enable_gcov - enable_largefile - enable_decimal_float - with_system_libunwind -@@ -1342,12 +1344,15 @@ Optional Features: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-shared don't provide a shared libgcc -+ --enable-off-stack-trampolines -+ Specify whether to support generating off-stack trampolines -+ -+ --disable-gcov don't provide libgcov and related host tools - --enable-vtable-verify Enable vtable verification feature - --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory - --enable-maintainer-mode - enable make rules and dependencies not useful (and - sometimes confusing) to the casual installer -- --disable-gcov don't provide libgcov and related host tools - --disable-largefile omit support for large files - --enable-decimal-float={no,yes,bid,dpd} - enable decimal float extension to C. Selecting 'bid' -@@ -2252,6 +2257,48 @@ fi - - - -+# Check whether --enable-off-stack-trampolines was given. -+if test "${enable_off_stack_trampolines+set}" = set; then : -+ enableval=$enable_off_stack_trampolines; -+case "$target" in -+ x86_64-*-linux* | x86_64-*-darwin1[4-9]* | x86_64-*-darwin2*) -+ off_stack_trampolines=$enableval -+ ;; -+ aarch64*-*-linux* ) -+ off_stack_trampolines=$enableval -+ ;; -+ aarch64*-*darwin* ) -+ off_stack_trampolines=$enableval -+ ;; -+ *) -+ as_fn_error $? "Configure option --enable-off-stack-trampolines is not supported \ -+for this platform" "$LINENO" 5 -+ off_stack_trampolines=no -+ ;; -+esac -+else -+ -+case "$target" in -+ *-*-darwin2*) -+ off_stack_trampolines=yes -+ ;; -+ *) -+ off_stack_trampolines=no -+ ;; -+esac -+fi -+ -+ -+ -+# Check whether --enable-gcov was given. -+if test "${enable_gcov+set}" = set; then : -+ enableval=$enable_gcov; -+else -+ enable_gcov=yes -+fi -+ -+ -+ - # Check whether --enable-vtable-verify was given. - if test "${enable_vtable_verify+set}" = set; then : - enableval=$enable_vtable_verify; case "$enableval" in -diff --git a/libgcc/configure.ac b/libgcc/configure.ac -index 2fc9d5d7c93..7d11bf00142 100644 ---- a/libgcc/configure.ac -+++ b/libgcc/configure.ac -@@ -68,6 +68,40 @@ AC_ARG_ENABLE(shared, - ], [enable_shared=yes]) - AC_SUBST(enable_shared) - -+AC_ARG_ENABLE([off-stack-trampolines], -+ [AS_HELP_STRING([--enable-off-stack-trampolines] -+ [Specify whether to support generating off-stack trampolines])],[ -+case "$target" in -+ x86_64-*-linux* | x86_64-*-darwin1[[4-9]]* | x86_64-*-darwin2*) -+ off_stack_trampolines=$enableval -+ ;; -+ aarch64*-*-linux* ) -+ off_stack_trampolines=$enableval -+ ;; -+ aarch64*-*darwin* ) -+ off_stack_trampolines=$enableval -+ ;; -+ *) -+ AC_MSG_ERROR([Configure option --enable-off-stack-trampolines is not supported \ -+for this platform]) -+ off_stack_trampolines=no -+ ;; -+esac],[ -+case "$target" in -+ *-*-darwin2*) -+ off_stack_trampolines=yes -+ ;; -+ *) -+ off_stack_trampolines=no -+ ;; -+esac]) -+AC_SUBST(off_stack_trampolines) -+ -+AC_ARG_ENABLE(gcov, -+[ --disable-gcov don't provide libgcov and related host tools], -+[], [enable_gcov=yes]) -+AC_SUBST(enable_gcov) -+ - AC_ARG_ENABLE(vtable-verify, - [ --enable-vtable-verify Enable vtable verification feature ], - [case "$enableval" in diff --git a/libgcc/libgcc-std.ver.in b/libgcc/libgcc-std.ver.in -index c4f87a50e70..a48f4899eb6 100644 +index c4f87a50e70..ad854bf0ded 100644 --- a/libgcc/libgcc-std.ver.in +++ b/libgcc/libgcc-std.ver.in -@@ -1943,4 +1943,7 @@ GCC_4.8.0 { - GCC_7.0.0 { +@@ -1944,3 +1944,9 @@ GCC_7.0.0 { __PFX__divmoddi4 __PFX__divmodti4 -+ -+ __builtin_nested_func_ptr_created -+ __builtin_nested_func_ptr_deleted } ++ ++%inherit GCC_14.0.0 GCC_7.0.0 ++GCC_14.0.0 { ++ __gcc_nested_func_ptr_created ++ __gcc_nested_func_ptr_deleted ++} diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h -index 3ec9bbd8164..ac7eaab4f01 100644 +index 3ec9bbd8164..a7a5dff0184 100644 --- a/libgcc/libgcc2.h +++ b/libgcc/libgcc2.h @@ -29,6 +29,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #pragma GCC visibility push(default) #endif -+extern void __builtin_nested_func_ptr_created (void *, void *, void **); -+extern void __builtin_nested_func_ptr_deleted (void); ++extern void __gcc_nested_func_ptr_created (void *, void *, void **); ++extern void __gcc_nested_func_ptr_deleted (void); + extern int __gcc_bcmp (const unsigned char *, const unsigned char *, size_t); extern void __clear_cache (void *, void *); extern void __eprintf (const char *, const char *, unsigned int, const char *) diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am -index 454ad12e701..2bc2e57919d 100644 +index 454ad12e701..3d21373ae82 100644 --- a/libgfortran/Makefile.am +++ b/libgfortran/Makefile.am @@ -37,6 +37,11 @@ else @@ -7331,7 +10220,7 @@ index 454ad12e701..2bc2e57919d 100644 endif +extra_darwin_ldflags_libgfortran = @extra_ldflags_libgfortran@ +if ENABLE_DARWIN_AT_RPATH -+extra_darwin_ldflags_libgfortran += -Wc,-nodefaultrpaths ++extra_darwin_ldflags_libgfortran += -Wc,-nodefaultrpaths +extra_darwin_ldflags_libgfortran += -Wl,-rpath,@loader_path +endif @@ -7460,7 +10349,7 @@ index 23df0761096..ed0d05f502a 100644 $(gfor_helper_src) $(gfor_ieee_src) $(gfor_io_headers) $(gfor_specific_src) diff --git a/libgfortran/configure b/libgfortran/configure -index d7c3a5e27a0..57a2c9d4946 100755 +index d7c3a5e27a0..feb75f6e55e 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -654,6 +654,8 @@ extra_ldflags_libgfortran @@ -7480,16 +10369,17 @@ index d7c3a5e27a0..57a2c9d4946 100755 enable_largefile enable_libquadmath_support with_gcc_major_version_only -@@ -1478,6 +1481,8 @@ Optional Features: +@@ -1478,6 +1481,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --disable-largefile omit support for large files --disable-libquadmath-support disable libquadmath support for Fortran -@@ -9235,7 +9240,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -9235,7 +9241,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -7498,7 +10388,7 @@ index d7c3a5e27a0..57a2c9d4946 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -10945,6 +10950,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10945,6 +10951,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -7548,7 +10438,7 @@ index d7c3a5e27a0..57a2c9d4946 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10962,9 +11010,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10962,9 +11011,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -7564,25 +10454,25 @@ index d7c3a5e27a0..57a2c9d4946 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12791,7 +12843,7 @@ else +@@ -12791,7 +12844,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12794 "configure" -+#line 12846 "configure" ++#line 12847 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12897,7 +12949,7 @@ else +@@ -12897,7 +12950,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12900 "configure" -+#line 12952 "configure" ++#line 12953 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13299,6 +13351,14 @@ esac +@@ -13299,6 +13352,14 @@ esac @@ -7597,7 +10487,7 @@ index d7c3a5e27a0..57a2c9d4946 100755 #AC_MSG_NOTICE([====== Finished libtool configuration]) ; sleep 10 # We need gfortran to compile parts of the library -@@ -14942,6 +15002,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -14942,6 +15003,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -7647,7 +10537,7 @@ index d7c3a5e27a0..57a2c9d4946 100755 archive_cmds_need_lc_FC=no hardcode_direct_FC=no hardcode_automatic_FC=yes -@@ -14959,9 +15062,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -14959,9 +15063,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -7663,7 +10553,7 @@ index d7c3a5e27a0..57a2c9d4946 100755 module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -16234,9 +16341,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +@@ -16234,9 +16342,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # extra LD Flags which are required for targets @@ -7676,7 +10566,7 @@ index d7c3a5e27a0..57a2c9d4946 100755 extra_ldflags_libgfortran=-Wl,-single_module ;; esac -@@ -31597,6 +31705,10 @@ if test -z "${HAVE_HWCAP_TRUE}" && test -z "${HAVE_HWCAP_FALSE}"; then +@@ -31597,6 +31706,10 @@ if test -z "${HAVE_HWCAP_TRUE}" && test -z "${HAVE_HWCAP_FALSE}"; then as_fn_error $? "conditional \"HAVE_HWCAP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -7740,9 +10630,30 @@ index 95df3ed7a30..aa35e747c9a 100644 # Subdir rules rely on $(FLAGS_TO_PASS) FLAGS_TO_PASS = $(AM_MAKEFLAGS) diff --git a/libgm2/Makefile.in b/libgm2/Makefile.in -index d9950065de1..f97f6d0812d 100644 +index 2b9592b3490..f97f6d0812d 100644 --- a/libgm2/Makefile.in +++ b/libgm2/Makefile.in +@@ -90,15 +90,15 @@ host_triplet = @host@ + target_triplet = @target@ + subdir = . + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \ +- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ +- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ +- $(top_srcdir)/../config/acx.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ +- $(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ @@ -344,6 +344,8 @@ GM2_SRC = $(GCC_DIR)/m2 SUBDIRS = libm2min libm2log libm2cor libm2iso libm2pim GM2_BUILDDIR := $(shell pwd) @@ -7762,8 +10673,32 @@ index d9950065de1..f97f6d0812d 100644 # Subdir rules rely on $(FLAGS_TO_PASS) +diff --git a/libgm2/aclocal.m4 b/libgm2/aclocal.m4 +index c352303012d..832065fbb9b 100644 +--- a/libgm2/aclocal.m4 ++++ b/libgm2/aclocal.m4 +@@ -1187,14 +1187,14 @@ AC_SUBST([am__tar]) + AC_SUBST([am__untar]) + ]) # _AM_PROG_TAR + +-m4_include([../libtool.m4]) +-m4_include([../ltoptions.m4]) +-m4_include([../ltsugar.m4]) +-m4_include([../ltversion.m4]) +-m4_include([../lt~obsolete.m4]) + m4_include([../config/acx.m4]) + m4_include([../config/depstand.m4]) + m4_include([../config/lead-dot.m4]) + m4_include([../config/multi.m4]) + m4_include([../config/no-executables.m4]) + m4_include([../config/override.m4]) ++m4_include([../libtool.m4]) ++m4_include([../ltoptions.m4]) ++m4_include([../ltsugar.m4]) ++m4_include([../ltversion.m4]) ++m4_include([../lt~obsolete.m4]) diff --git a/libgm2/configure b/libgm2/configure -index 8eb1bc81c66..d1a056a8a3b 100755 +index bf35b403a20..64f4f8034ce 100755 --- a/libgm2/configure +++ b/libgm2/configure @@ -649,6 +649,8 @@ GM2_FOR_TARGET @@ -7783,16 +10718,17 @@ index 8eb1bc81c66..d1a056a8a3b 100755 with_gcc_major_version_only ' ac_precious_vars='build_alias -@@ -1456,6 +1459,8 @@ Optional Features: +@@ -1456,6 +1459,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] -@@ -6575,10 +6580,6 @@ fi +@@ -6611,10 +6617,6 @@ fi @@ -7803,7 +10739,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -@@ -9149,7 +9150,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -9185,7 +9187,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -7812,7 +10748,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9197,6 +9198,8 @@ done +@@ -9233,6 +9235,8 @@ done @@ -7821,7 +10757,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 enable_win32_dll=no -@@ -10860,6 +10863,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10896,6 +10900,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -7871,7 +10807,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10877,9 +10923,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10913,9 +10960,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -7887,25 +10823,25 @@ index 8eb1bc81c66..d1a056a8a3b 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12706,7 +12756,7 @@ else +@@ -12742,7 +12793,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF --#line 12709 "configure" -+#line 12759 "configure" +-#line 12745 "configure" ++#line 12796 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12812,7 +12862,7 @@ else +@@ -12848,7 +12899,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF --#line 12815 "configure" -+#line 12865 "configure" +-#line 12851 "configure" ++#line 12902 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13694,6 +13744,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13730,6 +13781,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -7955,7 +10891,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -13711,12 +13804,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13747,12 +13841,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -7979,7 +10915,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -16090,6 +16191,21 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +@@ -16126,6 +16228,21 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu @@ -8001,7 +10937,7 @@ index 8eb1bc81c66..d1a056a8a3b 100755 if test "${multilib}" = "yes"; then -@@ -19873,6 +19989,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then +@@ -20314,6 +20431,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -8013,10 +10949,10 @@ index 8eb1bc81c66..d1a056a8a3b 100755 as_fn_error $? "conditional \"BUILD_PIMLIB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libgm2/configure.ac b/libgm2/configure.ac -index 3a79d2612b6..e8c7ba711cd 100644 +index 9386bbfe5ec..305d2dc4319 100644 --- a/libgm2/configure.ac +++ b/libgm2/configure.ac -@@ -177,8 +177,12 @@ AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error) +@@ -213,8 +213,12 @@ AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error) AC_PROG_MAKE_SET AC_PROG_INSTALL @@ -8031,7 +10967,7 @@ index 3a79d2612b6..e8c7ba711cd 100644 AC_SUBST(enable_static) diff --git a/libgm2/libm2cor/Makefile.am b/libgm2/libm2cor/Makefile.am -index 48de40c22dd..e50c7a2ef55 100644 +index ae96b4bfe78..a08e6a949e0 100644 --- a/libgm2/libm2cor/Makefile.am +++ b/libgm2/libm2cor/Makefile.am @@ -123,6 +123,10 @@ libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8046,20 +10982,36 @@ index 48de40c22dd..e50c7a2ef55 100644 BUILT_SOURCES = SYSTEM.def CLEANFILES = SYSTEM.def diff --git a/libgm2/libm2cor/Makefile.in b/libgm2/libm2cor/Makefile.in -index 9d643d5f8f6..d92c956aae6 100644 +index 8daf0eaa054..9e14c90ae7f 100644 --- a/libgm2/libm2cor/Makefile.in +++ b/libgm2/libm2cor/Makefile.in -@@ -105,6 +105,7 @@ POST_UNINSTALL = : +@@ -105,17 +105,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@BUILD_CORLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/ subdir = libm2cor ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ +-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \ +- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ +- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ +- $(top_srcdir)/../config/acx.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ +- $(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + DIST_COMMON = $(srcdir)/Makefile.am @@ -469,8 +470,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_CORLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \ - @BUILD_CORLIB_TRUE@ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2cor + @BUILD_CORLIB_TRUE@ -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2cor -@BUILD_CORLIB_TRUE@@TARGET_DARWIN_FALSE@libm2cor_la_link_flags = -@BUILD_CORLIB_TRUE@@TARGET_DARWIN_TRUE@libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8071,10 +11023,10 @@ index 9d643d5f8f6..d92c956aae6 100644 @BUILD_CORLIB_TRUE@BUILT_SOURCES = SYSTEM.def @BUILD_CORLIB_TRUE@CLEANFILES = SYSTEM.def diff --git a/libgm2/libm2iso/Makefile.am b/libgm2/libm2iso/Makefile.am -index d48ef0692ab..b0c4a5f965e 100644 +index 90d344f0fa8..e88c4b68e4f 100644 --- a/libgm2/libm2iso/Makefile.am +++ b/libgm2/libm2iso/Makefile.am -@@ -195,6 +195,10 @@ libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup +@@ -197,6 +197,10 @@ libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup else libm2iso_la_link_flags = endif @@ -8086,20 +11038,36 @@ index d48ef0692ab..b0c4a5f965e 100644 CLEANFILES = SYSTEM.def BUILT_SOURCES = SYSTEM.def diff --git a/libgm2/libm2iso/Makefile.in b/libgm2/libm2iso/Makefile.in -index b8936e745fe..7c7e181a01e 100644 +index 8d6443d3946..7be5ad1d601 100644 --- a/libgm2/libm2iso/Makefile.in +++ b/libgm2/libm2iso/Makefile.in -@@ -105,6 +105,7 @@ POST_UNINSTALL = : +@@ -105,17 +105,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@BUILD_ISOLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/ subdir = libm2iso ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ -@@ -568,8 +569,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) +-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \ +- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ +- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ +- $(top_srcdir)/../config/acx.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ +- $(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + DIST_COMMON = $(srcdir)/Makefile.am +@@ -570,8 +571,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_ISOLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \ - @BUILD_ISOLIB_TRUE@ -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2iso + @BUILD_ISOLIB_TRUE@ -fiso -fextended-opaque -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2iso -@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@libm2iso_la_link_flags = -@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8111,7 +11079,7 @@ index b8936e745fe..7c7e181a01e 100644 @BUILD_ISOLIB_TRUE@CLEANFILES = SYSTEM.def @BUILD_ISOLIB_TRUE@BUILT_SOURCES = SYSTEM.def diff --git a/libgm2/libm2log/Makefile.am b/libgm2/libm2log/Makefile.am -index a15747fd245..3b7609ee5c1 100644 +index 27f38406b07..25f5f9b0916 100644 --- a/libgm2/libm2log/Makefile.am +++ b/libgm2/libm2log/Makefile.am @@ -142,6 +142,9 @@ libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8125,20 +11093,36 @@ index a15747fd245..3b7609ee5c1 100644 BUILT_SOURCES = ../libm2pim/SYSTEM.def diff --git a/libgm2/libm2log/Makefile.in b/libgm2/libm2log/Makefile.in -index fa98b1d8ff1..cf48c2bb74f 100644 +index 2188f9ec0c5..f82ddb61842 100644 --- a/libgm2/libm2log/Makefile.in +++ b/libgm2/libm2log/Makefile.in -@@ -105,6 +105,7 @@ POST_UNINSTALL = : +@@ -105,17 +105,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@BUILD_LOGLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/ subdir = libm2log ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ +-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \ +- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ +- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ +- $(top_srcdir)/../config/acx.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ +- $(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + DIST_COMMON = $(srcdir)/Makefile.am @@ -478,8 +479,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_LOGLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \ - @BUILD_LOGLIB_TRUE@ -Wreturn-type -fcase -fm2-prefix=m2log + @BUILD_LOGLIB_TRUE@ -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2log -@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@libm2log_la_link_flags = -@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8164,17 +11148,33 @@ index 1ff160028f6..21411769505 100644 BUILT_SOURCES = SYSTEM.def CLEANFILES = SYSTEM.def diff --git a/libgm2/libm2min/Makefile.in b/libgm2/libm2min/Makefile.in -index 1c0bebdc304..ed3312deb0f 100644 +index 42cba0e37b9..ed3312deb0f 100644 --- a/libgm2/libm2min/Makefile.in +++ b/libgm2/libm2min/Makefile.in -@@ -105,6 +105,7 @@ POST_UNINSTALL = : +@@ -105,17 +105,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/ subdir = libm2min ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ +-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \ +- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ +- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ +- $(top_srcdir)/../config/acx.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ +- $(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + DIST_COMMON = $(srcdir)/Makefile.am @@ -442,8 +443,10 @@ libm2min_la_M2FLAGS = \ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs -fno-exceptions \ -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main -fm2-prefix=m2min @@ -8189,7 +11189,7 @@ index 1c0bebdc304..ed3312deb0f 100644 BUILT_SOURCES = SYSTEM.def CLEANFILES = SYSTEM.def diff --git a/libgm2/libm2pim/Makefile.am b/libgm2/libm2pim/Makefile.am -index ebfeba1ac1d..e777a60c077 100644 +index ac172b93337..61d6c814cc4 100644 --- a/libgm2/libm2pim/Makefile.am +++ b/libgm2/libm2pim/Makefile.am @@ -175,6 +175,9 @@ libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8203,20 +11203,36 @@ index ebfeba1ac1d..e777a60c077 100644 BUILT_SOURCES = SYSTEM.def CLEANFILES = SYSTEM.def diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in -index e5a97976d93..5e97a02a91d 100644 +index 4c2d574392b..0f3a6fe940e 100644 --- a/libgm2/libm2pim/Makefile.in +++ b/libgm2/libm2pim/Makefile.in -@@ -105,6 +105,7 @@ POST_UNINSTALL = : +@@ -105,17 +105,18 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ +@BUILD_PIMLIB_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -nodefaultrpaths -Wl,-rpath,@loader_path/ subdir = libm2pim ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ +-am__aclocal_m4_deps = $(top_srcdir)/../libtool.m4 \ +- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ +- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ +- $(top_srcdir)/../config/acx.m4 \ ++am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ +- $(top_srcdir)/../config/override.m4 $(top_srcdir)/configure.ac ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac + am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) + DIST_COMMON = $(srcdir)/Makefile.am @@ -539,8 +540,10 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_PIMLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \ - @BUILD_PIMLIB_TRUE@ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2pim + @BUILD_PIMLIB_TRUE@ -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2pim -@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@libm2pim_la_link_flags = -@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup @@ -8334,7 +11350,7 @@ index f1afb5ef57f..ef97186e68d 100644 libgomp_la_LIBADD = $(DL_LIBS) libgomp_la_DEPENDENCIES = $(libgomp_version_dep) diff --git a/libgomp/configure b/libgomp/configure -index ed18809ff1c..2d19357d123 100755 +index 389500df738..1c219c29f5e 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -682,6 +682,8 @@ FC @@ -8354,16 +11370,17 @@ index ed18809ff1c..2d19357d123 100755 enable_maintainer_mode enable_linux_futex enable_tls -@@ -1477,6 +1480,8 @@ Optional Features: +@@ -1477,6 +1480,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer -@@ -7621,7 +7626,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -7621,7 +7627,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -8372,7 +11389,7 @@ index ed18809ff1c..2d19357d123 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9594,6 +9599,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9594,6 +9600,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -8422,7 +11439,7 @@ index ed18809ff1c..2d19357d123 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9611,9 +9659,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9611,9 +9660,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -8438,25 +11455,25 @@ index ed18809ff1c..2d19357d123 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -11419,7 +11471,7 @@ else +@@ -11419,7 +11472,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11422 "configure" -+#line 11474 "configure" ++#line 11475 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11525,7 +11577,7 @@ else +@@ -11525,7 +11578,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11528 "configure" -+#line 11580 "configure" ++#line 11581 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11786,6 +11838,14 @@ esac +@@ -11786,6 +11839,14 @@ esac @@ -8471,7 +11488,7 @@ index ed18809ff1c..2d19357d123 100755 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 -@@ -13461,6 +13521,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13461,6 +13522,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -8521,7 +11538,7 @@ index ed18809ff1c..2d19357d123 100755 archive_cmds_need_lc_FC=no hardcode_direct_FC=no hardcode_automatic_FC=yes -@@ -13478,9 +13581,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13478,9 +13582,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -8537,7 +11554,7 @@ index ed18809ff1c..2d19357d123 100755 module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -17122,6 +17229,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then +@@ -17129,6 +17237,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then as_fn_error $? "conditional \"BUILD_INFO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -8549,7 +11566,7 @@ index ed18809ff1c..2d19357d123 100755 as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libgomp/configure.ac b/libgomp/configure.ac -index cc96e5b753b..cef33212028 100644 +index dd88f20103a..5deba114027 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -149,6 +149,7 @@ AM_PROG_LIBTOOL @@ -8700,7 +11717,7 @@ index 0342516cdc8..2c27f46dc43 100644 /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */ #define FEATURE_1_AND 0xc0000000 diff --git a/libitm/configure b/libitm/configure -index 6230c04dd24..014453a3f49 100755 +index 6230c04dd24..b941ecf83f9 100755 --- a/libitm/configure +++ b/libitm/configure @@ -660,6 +660,8 @@ libtool_VERSION @@ -8720,16 +11737,17 @@ index 6230c04dd24..014453a3f49 100755 enable_maintainer_mode enable_linux_futex enable_tls -@@ -1462,6 +1465,8 @@ Optional Features: +@@ -1462,6 +1465,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer -@@ -8283,7 +8288,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8283,7 +8289,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -8738,7 +11756,7 @@ index 6230c04dd24..014453a3f49 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -10257,6 +10262,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10257,6 +10263,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -8788,7 +11806,7 @@ index 6230c04dd24..014453a3f49 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10274,9 +10322,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10274,9 +10323,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -8804,25 +11822,25 @@ index 6230c04dd24..014453a3f49 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12082,7 +12134,7 @@ else +@@ -12082,7 +12135,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12085 "configure" -+#line 12137 "configure" ++#line 12138 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12188,7 +12240,7 @@ else +@@ -12188,7 +12241,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12191 "configure" -+#line 12243 "configure" ++#line 12244 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13064,6 +13116,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13064,6 +13117,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -8872,7 +11890,7 @@ index 6230c04dd24..014453a3f49 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -13081,12 +13176,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13081,12 +13177,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -8896,7 +11914,7 @@ index 6230c04dd24..014453a3f49 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -15458,6 +15561,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +@@ -15458,6 +15562,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu @@ -8911,7 +11929,7 @@ index 6230c04dd24..014453a3f49 100755 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 -@@ -18216,6 +18327,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then +@@ -18216,6 +18328,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then as_fn_error $? "conditional \"BUILD_INFO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -8947,44 +11965,8 @@ index 0362e61570a..2818a587ebf 100644 alpha*) ARCH=alpha ;; rs6000 | powerpc*) XCFLAGS="${XCFLAGS} -mhtm" -diff --git a/libitm/testsuite/lib/libitm.exp b/libitm/testsuite/lib/libitm.exp -index da918d1ee8d..61bbfa0c923 100644 ---- a/libitm/testsuite/lib/libitm.exp -+++ b/libitm/testsuite/lib/libitm.exp -@@ -159,6 +159,7 @@ proc libitm_init { args } { - } - - if [istarget *-*-darwin*] { -+ lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs" - lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc" - } - -diff --git a/libitm/testsuite/libitm.c++/c++.exp b/libitm/testsuite/libitm.c++/c++.exp -index de45e7e5480..1b0ead05fee 100644 ---- a/libitm/testsuite/libitm.c++/c++.exp -+++ b/libitm/testsuite/libitm.c++/c++.exp -@@ -56,8 +56,10 @@ if { $lang_test_file_found } { - # Gather a list of all tests. - set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] - -+ set stdcxxadder "" - if { $blddir != "" } { - set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" -+ set stdcxxadder "-B ${blddir}/${lang_library_path}" - } else { - set ld_library_path "$always_ld_library_path" - } -@@ -72,7 +74,7 @@ if { $lang_test_file_found } { - } - - # Main loop. -- dg-runtest $tests "" $libstdcxx_includes -+ dg-runtest $tests $stdcxxadder $libstdcxx_includes - } - - # All done. diff --git a/libobjc/configure b/libobjc/configure -index 6da20b8e4ff..7087d079450 100755 +index 6da20b8e4ff..ce18c249b66 100755 --- a/libobjc/configure +++ b/libobjc/configure @@ -636,6 +636,9 @@ OBJC_BOEHM_GC_LIBS @@ -9013,16 +11995,17 @@ index 6da20b8e4ff..7087d079450 100755 enable_tls enable_objc_gc with_target_bdw_gc -@@ -1392,6 +1395,8 @@ Optional Features: +@@ -1392,6 +1395,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-tls Use thread-local storage [default=yes] --enable-objc-gc enable use of Boehm's garbage collector with the GNU Objective-C runtime -@@ -3431,17 +3436,6 @@ esac +@@ -3431,17 +3437,6 @@ esac @@ -9040,7 +12023,7 @@ index 6da20b8e4ff..7087d079450 100755 # Add CET specific flags if CET is enabled -@@ -6973,7 +6967,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -6973,7 +6968,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -9049,7 +12032,7 @@ index 6da20b8e4ff..7087d079450 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -8950,6 +8944,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8950,6 +8945,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -9099,7 +12082,7 @@ index 6da20b8e4ff..7087d079450 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -8967,9 +9004,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8967,9 +9005,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -9115,25 +12098,25 @@ index 6da20b8e4ff..7087d079450 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -10796,7 +10837,7 @@ else +@@ -10796,7 +10838,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10799 "configure" -+#line 10840 "configure" ++#line 10841 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -10902,7 +10943,7 @@ else +@@ -10902,7 +10944,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10905 "configure" -+#line 10946 "configure" ++#line 10947 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11174,6 +11215,38 @@ $as_echo "no" >&6; } +@@ -11174,6 +11216,38 @@ $as_echo "no" >&6; } fi @@ -9172,7 +12155,7 @@ index 6da20b8e4ff..7087d079450 100755 # ------- # Headers # ------- -@@ -11915,6 +11988,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then +@@ -11915,6 +11989,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -9238,7 +12221,7 @@ index 9bd7d59d597..cb21ebbfcc7 100644 # Headers # ------- diff --git a/libphobos/configure b/libphobos/configure -index 925c53c5f5e..969ae6077cc 100755 +index 925c53c5f5e..2e8c06d4d48 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -707,6 +707,8 @@ get_gcc_base_ver @@ -9258,16 +12241,17 @@ index 925c53c5f5e..969ae6077cc 100755 with_gcc_major_version_only enable_werror with_libatomic -@@ -1490,6 +1493,8 @@ Optional Features: +@@ -1490,6 +1493,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-werror turns on -Werror [default=no] --enable-version-specific-runtime-libs Specify that runtime libraries should be installed -@@ -8244,7 +8249,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8244,7 +8250,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -9276,7 +12260,7 @@ index 925c53c5f5e..969ae6077cc 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9949,6 +9954,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9949,6 +9955,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -9326,7 +12310,7 @@ index 925c53c5f5e..969ae6077cc 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9966,9 +10014,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9966,9 +10015,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -9342,25 +12326,25 @@ index 925c53c5f5e..969ae6077cc 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -11774,7 +11826,7 @@ else +@@ -11774,7 +11827,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11777 "configure" -+#line 11829 "configure" ++#line 11830 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11880,7 +11932,7 @@ else +@@ -11880,7 +11933,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11883 "configure" -+#line 11935 "configure" ++#line 11936 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13405,6 +13457,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13405,6 +13458,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -9410,7 +12394,7 @@ index 925c53c5f5e..969ae6077cc 100755 archive_cmds_need_lc_D=no hardcode_direct_D=no hardcode_automatic_D=yes -@@ -13422,9 +13517,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13422,9 +13518,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -9426,7 +12410,7 @@ index 925c53c5f5e..969ae6077cc 100755 module_expsym_cmds_D="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -14026,6 +14125,14 @@ CFLAGS=$lt_save_CFLAGS +@@ -14026,6 +14126,14 @@ CFLAGS=$lt_save_CFLAGS @@ -9441,7 +12425,7 @@ index 925c53c5f5e..969ae6077cc 100755 # libtool variables for Phobos shared and position-independent compiles. # -@@ -15750,6 +15857,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then +@@ -15750,6 +15858,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -9529,7 +12513,7 @@ index a6229587e7b..cc3358b437e 100644 @ENABLE_LIBDRUNTIME_ONLY_FALSE@libgphobos_la_LIBADD = \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ ../libdruntime/libgdruntime_convenience.la $(LIBZ) diff --git a/libquadmath/Makefile.am b/libquadmath/Makefile.am -index 35dffb46f6e..0d02c95e738 100644 +index 35dffb46f6e..f199adf4602 100644 --- a/libquadmath/Makefile.am +++ b/libquadmath/Makefile.am @@ -36,8 +36,13 @@ endif @@ -9543,12 +12527,12 @@ index 35dffb46f6e..0d02c95e738 100644 +endif libquadmath_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ - $(version_arg) $(lt_host_flags) -lm -+ $(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath) ++ $(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath) libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD) nodist_libsubinclude_HEADERS = quadmath.h quadmath_weak.h diff --git a/libquadmath/Makefile.in b/libquadmath/Makefile.in -index 8c011212258..068af559457 100644 +index 8c011212258..70025758cd5 100644 --- a/libquadmath/Makefile.in +++ b/libquadmath/Makefile.in @@ -355,6 +355,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -9567,12 +12551,12 @@ index 8c011212258..068af559457 100644 +@BUILD_LIBQUADMATH_TRUE@@ENABLE_DARWIN_AT_RPATH_TRUE@ -Wl,-rpath,@loader_path @BUILD_LIBQUADMATH_TRUE@libquadmath_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ -@BUILD_LIBQUADMATH_TRUE@ $(version_arg) $(lt_host_flags) -lm -+@BUILD_LIBQUADMATH_TRUE@ $(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath) ++@BUILD_LIBQUADMATH_TRUE@ $(version_arg) $(lt_host_flags) $(LIBM) $(libquadmath_darwin_rpath) @BUILD_LIBQUADMATH_TRUE@libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD) @BUILD_LIBQUADMATH_TRUE@nodist_libsubinclude_HEADERS = quadmath.h quadmath_weak.h diff --git a/libquadmath/configure b/libquadmath/configure -index 958fb876c5b..9b1703d6ee5 100755 +index 958fb876c5b..c51d4f3776c 100755 --- a/libquadmath/configure +++ b/libquadmath/configure @@ -644,11 +644,14 @@ LIBQUAD_USE_SYMVER_GNU_FALSE @@ -9598,16 +12582,17 @@ index 958fb876c5b..9b1703d6ee5 100755 enable_maintainer_mode with_toolexeclibdir enable_symvers -@@ -1435,6 +1439,8 @@ Optional Features: +@@ -1435,6 +1439,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer -@@ -7272,7 +7278,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -7272,7 +7279,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -9616,7 +12601,7 @@ index 958fb876c5b..9b1703d6ee5 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -8984,6 +8990,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8984,6 +8991,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -9666,7 +12651,7 @@ index 958fb876c5b..9b1703d6ee5 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9001,9 +9050,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9001,9 +9051,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -9682,25 +12667,25 @@ index 958fb876c5b..9b1703d6ee5 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -10830,7 +10883,7 @@ else +@@ -10830,7 +10884,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10833 "configure" -+#line 10886 "configure" ++#line 10887 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -10936,7 +10989,7 @@ else +@@ -10936,7 +10990,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10939 "configure" -+#line 10992 "configure" ++#line 10993 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11197,6 +11250,14 @@ esac +@@ -11197,6 +11251,14 @@ esac @@ -9715,156 +12700,28 @@ index 958fb876c5b..9b1703d6ee5 100755 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 -@@ -12161,6 +12222,148 @@ esac +@@ -12161,6 +12223,20 @@ esac ++# AC_CHECK_LIBM variant which avoids AC_CHECK_LIB (that doesn't work ++# on bare metal). In the past we've used -lm in Makefile.am unconditionally, ++# let's use it there unless target knows it doesn't need that. +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; -+*-ncr-sysv4.3*) -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _mwvalidcheckl in -lmw" >&5 -+$as_echo_n "checking for _mwvalidcheckl in -lmw... " >&6; } -+if ${ac_cv_lib_mw__mwvalidcheckl+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lmw $LIBS" -+if test x$gcc_no_link = xyes; then -+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 -+fi -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char _mwvalidcheckl (); -+int -+main () -+{ -+return _mwvalidcheckl (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_mw__mwvalidcheckl=yes -+else -+ ac_cv_lib_mw__mwvalidcheckl=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mw__mwvalidcheckl" >&5 -+$as_echo "$ac_cv_lib_mw__mwvalidcheckl" >&6; } -+if test "x$ac_cv_lib_mw__mwvalidcheckl" = xyes; then : -+ LIBM="-lmw" -+fi -+ -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 -+$as_echo_n "checking for cos in -lm... " >&6; } -+if ${ac_cv_lib_m_cos+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lm $LIBS" -+if test x$gcc_no_link = xyes; then -+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 -+fi -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char cos (); -+int -+main () -+{ -+return cos (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_m_cos=yes -+else -+ ac_cv_lib_m_cos=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 -+$as_echo "$ac_cv_lib_m_cos" >&6; } -+if test "x$ac_cv_lib_m_cos" = xyes; then : -+ LIBM="$LIBM -lm" -+fi -+ -+ ;; +*) -+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 -+$as_echo_n "checking for cos in -lm... " >&6; } -+if ${ac_cv_lib_m_cos+:} false; then : -+ $as_echo_n "(cached) " >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lm $LIBS" -+if test x$gcc_no_link = xyes; then -+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 -+fi -+cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+ -+/* Override any GCC internal prototype to avoid an error. -+ Use char because int might match the return type of a GCC -+ builtin and then its argument prototype would still apply. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+char cos (); -+int -+main () -+{ -+return cos (); -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_lib_m_cos=yes -+else -+ ac_cv_lib_m_cos=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 -+$as_echo "$ac_cv_lib_m_cos" >&6; } -+if test "x$ac_cv_lib_m_cos" = xyes; then : -+ LIBM="-lm" -+fi -+ ++ LIBM=-lm + ;; +esac + -+ + for ac_header in fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -@@ -13421,6 +13624,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then +@@ -13421,6 +13497,10 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then as_fn_error $? "conditional \"BUILD_INFO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -9876,7 +12733,7 @@ index 958fb876c5b..9b1703d6ee5 100755 as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libquadmath/configure.ac b/libquadmath/configure.ac -index eec4084a45f..94a3f2179e9 100644 +index eec4084a45f..349be2607c6 100644 --- a/libquadmath/configure.ac +++ b/libquadmath/configure.ac @@ -59,6 +59,7 @@ AM_PROG_LIBTOOL @@ -9887,11 +12744,23 @@ index eec4084a45f..94a3f2179e9 100644 AM_MAINTAINER_MODE -@@ -121,6 +122,8 @@ esac +@@ -121,6 +122,20 @@ esac AC_SUBST(toolexecdir) AC_SUBST(toolexeclibdir) -+AC_CHECK_LIBM ++# AC_CHECK_LIBM variant which avoids AC_CHECK_LIB (that doesn't work ++# on bare metal). In the past we've used -lm in Makefile.am unconditionally, ++# let's use it there unless target knows it doesn't need that. ++LIBM= ++case $host in ++*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) ++ # These system don't have libm, or don't need it ++ ;; ++*) ++ LIBM=-lm ++ ;; ++esac ++AC_SUBST([LIBM]) + AC_CHECK_HEADERS(fenv.h langinfo.h locale.h wchar.h wctype.h limits.h ctype.h printf.h errno.h) LIBQUAD_CHECK_MATH_H_SIGNGAM @@ -9933,7 +12802,7 @@ index 7833a9a4c3f..e88e5e0b0a7 100644 # Work around what appears to be a GNU make bug handling MAKEFLAGS # values defined in terms of make variables, as is the case for CC and diff --git a/libsanitizer/configure b/libsanitizer/configure -index e7984f96615..43b8b1b0737 100755 +index e7984f96615..dac83083e30 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure @@ -666,6 +666,8 @@ LSAN_SUPPORTED_FALSE @@ -9953,16 +12822,17 @@ index e7984f96615..43b8b1b0737 100755 enable_werror with_gcc_major_version_only enable_cet -@@ -1471,6 +1474,8 @@ Optional Features: +@@ -1471,6 +1474,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --disable-werror disable building with -Werror --enable-cet enable Intel CET in target libraries [default=auto] -@@ -8853,7 +8858,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8853,7 +8859,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -9971,7 +12841,7 @@ index e7984f96615..43b8b1b0737 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -10558,6 +10563,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10558,6 +10564,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -10021,7 +12891,7 @@ index e7984f96615..43b8b1b0737 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10575,9 +10623,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10575,9 +10624,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -10037,25 +12907,25 @@ index e7984f96615..43b8b1b0737 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12383,7 +12435,7 @@ else +@@ -12383,7 +12436,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12386 "configure" -+#line 12438 "configure" ++#line 12439 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12489,7 +12541,7 @@ else +@@ -12489,7 +12542,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12492 "configure" -+#line 12544 "configure" ++#line 12545 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13365,6 +13417,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13365,6 +13418,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -10105,7 +12975,7 @@ index e7984f96615..43b8b1b0737 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -13382,12 +13477,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13382,12 +13478,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -10129,7 +12999,7 @@ index e7984f96615..43b8b1b0737 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -15807,6 +15910,15 @@ esac +@@ -15807,6 +15911,15 @@ esac @@ -10145,7 +13015,7 @@ index e7984f96615..43b8b1b0737 100755 # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -@@ -17205,6 +17317,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then +@@ -17205,6 +17318,10 @@ if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -10352,7 +13222,7 @@ index bc8a0dc2b28..1cf86361b96 100644 libssp_nonshared_la_SOURCES = \ ssp-local.c diff --git a/libssp/configure b/libssp/configure -index 492915d2ce0..7a3c784aaf4 100755 +index 492915d2ce0..72102be1742 100755 --- a/libssp/configure +++ b/libssp/configure @@ -636,6 +636,8 @@ LIBOBJS @@ -10372,16 +13242,17 @@ index 492915d2ce0..7a3c784aaf4 100755 with_toolexeclibdir with_gcc_major_version_only ' -@@ -1426,6 +1429,8 @@ Optional Features: +@@ -1426,6 +1429,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] -@@ -7458,7 +7463,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -7458,7 +7464,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -10390,7 +13261,7 @@ index 492915d2ce0..7a3c784aaf4 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -9170,6 +9175,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9170,6 +9176,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -10440,7 +13311,7 @@ index 492915d2ce0..7a3c784aaf4 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -9187,9 +9235,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -9187,9 +9236,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -10456,25 +13327,25 @@ index 492915d2ce0..7a3c784aaf4 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -11016,7 +11068,7 @@ else +@@ -11016,7 +11069,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11019 "configure" -+#line 11071 "configure" ++#line 11072 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11122,7 +11174,7 @@ else +@@ -11122,7 +11175,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11125 "configure" -+#line 11177 "configure" ++#line 11178 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11400,6 +11452,15 @@ fi +@@ -11400,6 +11453,15 @@ fi @@ -10490,7 +13361,7 @@ index 492915d2ce0..7a3c784aaf4 100755 # Calculate toolexeclibdir # Also toolexecdir, though it's only used in toolexeclibdir case ${version_specific_libs} in -@@ -11609,6 +11670,10 @@ if test -z "${LIBSSP_USE_SYMVER_SUN_TRUE}" && test -z "${LIBSSP_USE_SYMVER_SUN_F +@@ -11609,6 +11671,10 @@ if test -z "${LIBSSP_USE_SYMVER_SUN_TRUE}" && test -z "${LIBSSP_USE_SYMVER_SUN_F as_fn_error $? "conditional \"LIBSSP_USE_SYMVER_SUN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -10515,19 +13386,19 @@ index f30f81c54f6..90778e2355d 100644 # Also toolexecdir, though it's only used in toolexeclibdir case ${version_specific_libs} in diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure -index 9b602777545..7f1874c413a 100755 +index d35baaf7c6e..4cac54b99c9 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure -@@ -789,6 +789,8 @@ GLIBCXX_HOSTED_TRUE - glibcxx_compiler_shared_flag - glibcxx_compiler_pic_flag +@@ -791,6 +791,8 @@ glibcxx_compiler_pic_flag glibcxx_lt_pic_flag + OS_IS_DARWIN_FALSE + OS_IS_DARWIN_TRUE +ENABLE_DARWIN_AT_RPATH_FALSE +ENABLE_DARWIN_AT_RPATH_TRUE enable_static enable_shared lt_host_flags -@@ -924,6 +926,7 @@ with_pic +@@ -926,6 +928,7 @@ with_pic enable_fast_install with_gnu_ld enable_libtool_lock @@ -10535,16 +13406,17 @@ index 9b602777545..7f1874c413a 100755 enable_hosted_libstdcxx enable_libstdcxx_hosted enable_libstdcxx_verbose -@@ -1615,6 +1618,8 @@ Optional Features: +@@ -1617,6 +1620,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --disable-hosted-libstdcxx only build freestanding C++ runtime support --disable-libstdcxx-hosted -@@ -8501,7 +8506,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8503,7 +8509,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -10553,7 +13425,7 @@ index 9b602777545..7f1874c413a 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -10341,6 +10346,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10343,6 +10349,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -10603,7 +13475,7 @@ index 9b602777545..7f1874c413a 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10358,9 +10406,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10360,9 +10409,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -10619,25 +13491,25 @@ index 9b602777545..7f1874c413a 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12187,7 +12239,7 @@ else +@@ -12189,7 +12242,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF --#line 12190 "configure" -+#line 12242 "configure" +-#line 12192 "configure" ++#line 12245 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12293,7 +12345,7 @@ else +@@ -12295,7 +12348,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF --#line 12296 "configure" -+#line 12348 "configure" +-#line 12298 "configure" ++#line 12351 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13175,6 +13227,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13177,6 +13230,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -10687,7 +13559,7 @@ index 9b602777545..7f1874c413a 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -13192,12 +13287,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13194,12 +13290,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -10711,7 +13583,7 @@ index 9b602777545..7f1874c413a 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -15594,6 +15697,14 @@ esac +@@ -15596,6 +15700,14 @@ esac @@ -10724,63 +13596,63 @@ index 9b602777545..7f1874c413a 100755 +fi + - if test "$enable_vtable_verify" = yes; then - predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o" -@@ -16017,7 +16128,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } + os_is_darwin=no + case ${host_os} in +@@ -16033,7 +16145,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF --#line 16020 "configure" -+#line 16131 "configure" +-#line 16036 "configure" ++#line 16148 "configure" int main() { typedef bool atomic_type; -@@ -16052,7 +16163,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } +@@ -16068,7 +16180,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF --#line 16055 "configure" -+#line 16166 "configure" +-#line 16071 "configure" ++#line 16183 "configure" int main() { typedef short atomic_type; -@@ -16087,7 +16198,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } +@@ -16103,7 +16215,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF --#line 16090 "configure" -+#line 16201 "configure" +-#line 16106 "configure" ++#line 16218 "configure" int main() { // NB: _Atomic_word not necessarily int. -@@ -16123,7 +16234,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } +@@ -16139,7 +16251,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF --#line 16126 "configure" -+#line 16237 "configure" +-#line 16142 "configure" ++#line 16254 "configure" int main() { typedef long long atomic_type; -@@ -16279,7 +16390,7 @@ $as_echo "mutex" >&6; } +@@ -16295,7 +16407,7 @@ $as_echo "mutex" >&6; } # unnecessary for this test. cat > conftest.$ac_ext << EOF --#line 16282 "configure" -+#line 16393 "configure" +-#line 16298 "configure" ++#line 16410 "configure" int main() { _Decimal32 d1; -@@ -16321,7 +16432,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +@@ -16337,7 +16449,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF --#line 16324 "configure" -+#line 16435 "configure" +-#line 16340 "configure" ++#line 16452 "configure" template struct same { typedef T2 type; }; -@@ -73038,6 +73149,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then +@@ -73309,6 +73421,10 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -10788,11 +13660,11 @@ index 9b602777545..7f1874c413a 100755 + as_fn_error $? "conditional \"ENABLE_DARWIN_AT_RPATH\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi - if test -z "${GLIBCXX_HOSTED_TRUE}" && test -z "${GLIBCXX_HOSTED_FALSE}"; then - as_fn_error $? "conditional \"GLIBCXX_HOSTED\" was never defined. + if test -z "${OS_IS_DARWIN_TRUE}" && test -z "${OS_IS_DARWIN_FALSE}"; then + as_fn_error $? "conditional \"OS_IS_DARWIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac -index 91b3c1f32f2..8832c70de3c 100644 +index 0c3c7a2c11c..6dde72ca566 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -108,6 +108,7 @@ AM_PROG_LIBTOOL @@ -10801,8 +13673,8 @@ index 91b3c1f32f2..8832c70de3c 100644 AC_SUBST(enable_static) +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes]) - if test "$enable_vtable_verify" = yes; then - predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o" + os_is_darwin=no + case ${host_os} in diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 5b9af41cdb9..925137c2ccc 100644 --- a/libstdc++-v3/src/Makefile.am @@ -10840,7 +13712,7 @@ index f42d957af36..0ce75f30708 100644 libstdc___la_LINK = $(CXXLINK) $(libstdc___la_LDFLAGS) $(lt_host_flags) @GLIBCXX_LDBL_ALT128_COMPAT_FALSE@@GLIBCXX_LDBL_COMPAT_TRUE@LTCXXCOMPILE64 = $(LTCXXCOMPILE) diff --git a/libtool.m4 b/libtool.m4 -index b92e284d9f9..f3bddafc19d 100644 +index b92e284d9f9..5361f2619cc 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -1005,7 +1005,7 @@ _LT_EOF @@ -10865,7 +13737,7 @@ index b92e284d9f9..f3bddafc19d 100644 + # configuring can override the defaults for any system version that supports + # them - they are, however, forced off for system versions without support. + AC_ARG_ENABLE([darwin-at-rpath], -+ AS_HELP_STRING([--enable-darwin-at-path], ++ AS_HELP_STRING([--enable-darwin-at-rpath], + [install libraries with @rpath/library-name, requires rpaths to be added to executables]), + [if test "x$enable_darwin_at_rpath" = "xyes"; then + # This is not supported before macOS 10.5 / Darwin9. @@ -10923,15 +13795,7 @@ index b92e284d9f9..f3bddafc19d 100644 _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) -@@ -4227,6 +4274,7 @@ _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) - ])# _LT_COMPILER_PIC - -+_LT_TAGVAR(enable_darwin_at_rpath, $1)=no - - # _LT_LINKER_SHLIBS([TAGNAME]) - # ---------------------------- -@@ -6466,7 +6514,6 @@ fi # test "$_lt_caught_CXX_error" != yes +@@ -6466,7 +6513,6 @@ fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG @@ -10940,7 +13804,7 @@ index b92e284d9f9..f3bddafc19d 100644 # --------------------------------- # Figure out "hidden" library dependencies from verbose diff --git a/libvtv/configure b/libvtv/configure -index e7e490d8b3e..f09f4d9dbcf 100755 +index e7e490d8b3e..da4fe61d0cf 100755 --- a/libvtv/configure +++ b/libvtv/configure @@ -640,6 +640,8 @@ VTV_CYGMIN_FALSE @@ -10960,16 +13824,17 @@ index e7e490d8b3e..f09f4d9dbcf 100755 enable_cet with_gcc_major_version_only ' -@@ -1446,6 +1449,8 @@ Optional Features: +@@ -1446,6 +1449,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-cet enable Intel CET in target libraries [default=auto] Optional Packages: -@@ -8748,7 +8753,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8748,7 +8754,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -10978,7 +13843,7 @@ index e7e490d8b3e..f09f4d9dbcf 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -10453,6 +10458,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10453,6 +10459,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -11028,7 +13893,7 @@ index e7e490d8b3e..f09f4d9dbcf 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10470,9 +10518,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10470,9 +10519,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -11044,25 +13909,25 @@ index e7e490d8b3e..f09f4d9dbcf 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12278,7 +12330,7 @@ else +@@ -12278,7 +12331,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12281 "configure" -+#line 12333 "configure" ++#line 12334 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12384,7 +12436,7 @@ else +@@ -12384,7 +12437,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12387 "configure" -+#line 12439 "configure" ++#line 12440 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -13260,6 +13312,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13260,6 +13313,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -11112,7 +13977,7 @@ index e7e490d8b3e..f09f4d9dbcf 100755 archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes -@@ -13277,12 +13372,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -13277,12 +13373,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -11136,7 +14001,7 @@ index e7e490d8b3e..f09f4d9dbcf 100755 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi -@@ -15676,6 +15779,14 @@ esac +@@ -15676,6 +15780,14 @@ esac @@ -11151,7 +14016,7 @@ index e7e490d8b3e..f09f4d9dbcf 100755 # For libtool versioning info, format is CURRENT:REVISION:AGE libtool_VERSION=1:0:0 -@@ -16021,6 +16132,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then +@@ -16021,6 +16133,10 @@ if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -11175,7 +14040,7 @@ index f3b937e4b10..50aaadbb3a3 100644 # For libtool versioning info, format is CURRENT:REVISION:AGE libtool_VERSION=1:0:0 diff --git a/lto-plugin/configure b/lto-plugin/configure -index d522bd24c95..23162fc0fff 100755 +index d522bd24c95..c3b1b5fe0b5 100755 --- a/lto-plugin/configure +++ b/lto-plugin/configure @@ -634,6 +634,8 @@ LTLIBOBJS @@ -11195,16 +14060,17 @@ index d522bd24c95..23162fc0fff 100755 ' ac_precious_vars='build_alias host_alias -@@ -1431,6 +1434,8 @@ Optional Features: +@@ -1431,6 +1434,9 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] -@@ -8603,7 +8608,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -8603,7 +8609,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -11213,7 +14079,7 @@ index d522bd24c95..23162fc0fff 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -10309,6 +10314,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10309,6 +10315,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -11263,7 +14129,7 @@ index d522bd24c95..23162fc0fff 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -10326,9 +10374,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -10326,9 +10375,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -11279,25 +14145,25 @@ index d522bd24c95..23162fc0fff 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -12134,7 +12186,7 @@ else +@@ -12134,7 +12187,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12137 "configure" -+#line 12189 "configure" ++#line 12190 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12240,7 +12292,7 @@ else +@@ -12240,7 +12293,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12243 "configure" -+#line 12295 "configure" ++#line 12296 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -12477,6 +12529,14 @@ CC="$lt_save_CC" +@@ -12477,6 +12530,14 @@ CC="$lt_save_CC" # Only expand once: @@ -11312,7 +14178,7 @@ index d522bd24c95..23162fc0fff 100755 -@@ -12723,6 +12783,10 @@ if test -z "${LTO_PLUGIN_USE_SYMVER_SUN_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMV +@@ -12723,6 +12784,10 @@ if test -z "${LTO_PLUGIN_USE_SYMVER_SUN_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMV as_fn_error $? "conditional \"LTO_PLUGIN_USE_SYMVER_SUN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -11349,7 +14215,7 @@ index 3f5102d1b87..80fe3b69116 100644 host = @host@ host_alias = @host_alias@ diff --git a/zlib/configure b/zlib/configure -index e35ac6e7e17..ccafc4f03f7 100755 +index e35ac6e7e17..a7673a840ab 100755 --- a/zlib/configure +++ b/zlib/configure @@ -635,10 +635,14 @@ am__EXEEXT_TRUE @@ -11378,18 +14244,19 @@ index e35ac6e7e17..ccafc4f03f7 100755 ' ac_precious_vars='build_alias host_alias -@@ -1419,7 +1425,10 @@ Optional Features: +@@ -1419,7 +1425,11 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) -+ --enable-darwin-at-path install libraries with @rpath/library-name, requires ++ --enable-darwin-at-rpath ++ install libraries with @rpath/library-name, requires + rpaths to be added to executables --enable-host-shared build host code as shared libraries + --enable-host-pie build host code as PIE Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] -@@ -6934,7 +6943,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } +@@ -6934,7 +6944,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } # darwin 5.x (macOS 10.1) onwards we only need to adjust when the # deployment target is forced to an earlier version. case ${MACOSX_DEPLOYMENT_TARGET-UNSET},$host in @@ -11398,7 +14265,7 @@ index e35ac6e7e17..ccafc4f03f7 100755 ;; 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' -@@ -8913,6 +8922,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8913,6 +8923,49 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi darwin* | rhapsody*) @@ -11448,7 +14315,7 @@ index e35ac6e7e17..ccafc4f03f7 100755 archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes -@@ -8930,9 +8982,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +@@ -8930,9 +8983,13 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all @@ -11464,25 +14331,25 @@ index e35ac6e7e17..ccafc4f03f7 100755 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else -@@ -10759,7 +10815,7 @@ else +@@ -10759,7 +10816,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10762 "configure" -+#line 10818 "configure" ++#line 10819 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -10865,7 +10921,7 @@ else +@@ -10865,7 +10922,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10868 "configure" -+#line 10924 "configure" ++#line 10925 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -@@ -11102,6 +11158,14 @@ CC="$lt_save_CC" +@@ -11102,6 +11159,14 @@ CC="$lt_save_CC" # Only expand once: @@ -11497,7 +14364,7 @@ index e35ac6e7e17..ccafc4f03f7 100755 # Find CPP now so that any conditional tests below won't do it and # thereby make the resulting definitions conditional. -@@ -11548,15 +11612,31 @@ else +@@ -11548,15 +11613,31 @@ else multilib_arg= fi @@ -11531,7 +14398,7 @@ index e35ac6e7e17..ccafc4f03f7 100755 ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF -@@ -11732,6 +11812,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then +@@ -11732,6 +11813,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi From 9542b0d915ced791f64813de8997505d8b7ef66b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 27 Jul 2024 17:32:16 -0700 Subject: [PATCH 52/91] build/pkgs/gcc: Remove upstreamed patches --- ...7560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch | 138 ------------------ ...b9e60ce1d9aa7751d79291133fd5af9209d7.patch | 64 -------- .../gcc/patches/gcc-xcode15-warnings.patch | 25 ---- 3 files changed, 227 deletions(-) delete mode 100644 build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch delete mode 100644 build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch delete mode 100644 build/pkgs/gcc/patches/gcc-xcode15-warnings.patch diff --git a/build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch b/build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch deleted file mode 100644 index 0672eb2936e..00000000000 --- a/build/pkgs/gcc/patches/68057560ff1fc0fb2df38c2f9627a20c9a8da5c5.patch +++ /dev/null @@ -1,138 +0,0 @@ -From: Francois-Xavier Coudert -Date: Thu, 7 Mar 2024 13:36:03 +0000 (+0100) -Subject: Include safe-ctype.h after C++ standard headers, to avoid over-poisoning -X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=68057560ff1fc0fb2df38c2f9627a20c9a8da5c5 - -Include safe-ctype.h after C++ standard headers, to avoid over-poisoning - -When building gcc's C++ sources against recent libc++, the poisoning of -the ctype macros due to including safe-ctype.h before including C++ -standard headers such as , , etc, causes many compilation -errors, similar to: - - In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23: - In file included from /home/dim/src/gcc/master/gcc/system.h:233: - In file included from /usr/include/c++/v1/vector:321: - In file included from - /usr/include/c++/v1/__format/formatter_bool.h:20: - In file included from - /usr/include/c++/v1/__format/formatter_integral.h:32: - In file included from /usr/include/c++/v1/locale:202: - /usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute - only applies to structs, variables, functions, and namespaces - 546 | _LIBCPP_INLINE_VISIBILITY - | ^ - /usr/include/c++/v1/__config:813:37: note: expanded from macro - '_LIBCPP_INLINE_VISIBILITY' - 813 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI - | ^ - /usr/include/c++/v1/__config:792:26: note: expanded from macro - '_LIBCPP_HIDE_FROM_ABI' - 792 | - __attribute__((__abi_tag__(_LIBCPP_TOSTRING( - _LIBCPP_VERSIONED_IDENTIFIER)))) - | ^ - In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23: - In file included from /home/dim/src/gcc/master/gcc/system.h:233: - In file included from /usr/include/c++/v1/vector:321: - In file included from - /usr/include/c++/v1/__format/formatter_bool.h:20: - In file included from - /usr/include/c++/v1/__format/formatter_integral.h:32: - In file included from /usr/include/c++/v1/locale:202: - /usr/include/c++/v1/__locale:547:37: error: expected ';' at end of - declaration list - 547 | char_type toupper(char_type __c) const - | ^ - /usr/include/c++/v1/__locale:553:48: error: too many arguments - provided to function-like macro invocation - 553 | const char_type* toupper(char_type* __low, const - char_type* __high) const - | ^ - /home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note: - macro 'toupper' defined here - 146 | #define toupper(c) do_not_use_toupper_with_safe_ctype - | ^ - -This is because libc++ uses different transitive includes than -libstdc++, and some of those transitive includes pull in various ctype -declarations (typically via ). - -There was already a special case for including before -safe-ctype.h, so move the rest of the C++ standard header includes to -the same location, to fix the problem. - - PR middle-end/111632 - -gcc/ChangeLog: - - * system.h: Include safe-ctype.h after C++ standard headers. - -Signed-off-by: Dimitry Andric -(cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a) ---- - -diff --git a/gcc/system.h b/gcc/system.h -index 33e9d4211150..03ab33ac960f 100644 ---- a/gcc/system.h -+++ b/gcc/system.h -@@ -194,27 +194,8 @@ extern int fprintf_unlocked (FILE *, const char *, ...); - #undef fread_unlocked - #undef fwrite_unlocked - --/* Include before "safe-ctype.h" to avoid GCC poisoning -- the ctype macros through safe-ctype.h */ -- --#ifdef __cplusplus --#ifdef INCLUDE_STRING --# include --#endif --#endif -- --/* There are an extraordinary number of issues with . -- The last straw is that it varies with the locale. Use libiberty's -- replacement instead. */ --#include "safe-ctype.h" -- --#include -- --#include -- --#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO --extern int errno; --#endif -+/* Include C++ standard headers before "safe-ctype.h" to avoid GCC -+ poisoning the ctype macros through safe-ctype.h */ - - #ifdef __cplusplus - #if defined (INCLUDE_ALGORITHM) || !defined (HAVE_SWAP_IN_UTILITY) -@@ -229,6 +210,9 @@ extern int errno; - #ifdef INCLUDE_SET - # include - #endif -+#ifdef INCLUDE_STRING -+# include -+#endif - #ifdef INCLUDE_VECTOR - # include - #endif -@@ -245,6 +229,19 @@ extern int errno; - # include - #endif - -+/* There are an extraordinary number of issues with . -+ The last straw is that it varies with the locale. Use libiberty's -+ replacement instead. */ -+#include "safe-ctype.h" -+ -+#include -+ -+#include -+ -+#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO -+extern int errno; -+#endif -+ - /* Some of glibc's string inlines cause warnings. Plus we'd rather - rely on (and therefore test) GCC's string builtins. */ - #define __NO_STRING_INLINES diff --git a/build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch b/build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch deleted file mode 100644 index 6fb61b58ed2..00000000000 --- a/build/pkgs/gcc/patches/e95ab9e60ce1d9aa7751d79291133fd5af9209d7.patch +++ /dev/null @@ -1,64 +0,0 @@ -From: Francois-Xavier Coudert -Date: Sat, 16 Mar 2024 08:50:00 +0000 (+0100) -Subject: libcc1: fix include -X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=e95ab9e60ce1d9aa7751d79291133fd5af9209d7 - -libcc1: fix include - -Use INCLUDE_VECTOR before including system.h, instead of directly -including , to avoid running into poisoned identifiers. - -Signed-off-by: Dimitry Andric - - PR middle-end/111632 - -libcc1/ChangeLog: - - * libcc1plugin.cc: Fix include. - * libcp1plugin.cc: Fix include. - -(cherry picked from commit 5213047b1d50af63dfabb5e5649821a6cb157e33) ---- - -diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc -index 7e0fecae1456..44bcf56698ee 100644 ---- a/libcc1/libcc1plugin.cc -+++ b/libcc1/libcc1plugin.cc -@@ -32,6 +32,7 @@ - #undef PACKAGE_VERSION - - #define INCLUDE_MEMORY -+#define INCLUDE_VECTOR - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" -@@ -69,8 +70,6 @@ - #include "gcc-c-interface.h" - #include "context.hh" - --#include -- - using namespace cc1_plugin; - - -diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc -index 8d394c0cfdb8..9586a2afdb47 100644 ---- a/libcc1/libcp1plugin.cc -+++ b/libcc1/libcp1plugin.cc -@@ -33,6 +33,7 @@ - #undef PACKAGE_VERSION - - #define INCLUDE_MEMORY -+#define INCLUDE_VECTOR - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" -@@ -71,8 +72,6 @@ - #include "rpc.hh" - #include "context.hh" - --#include -- - using namespace cc1_plugin; - - diff --git a/build/pkgs/gcc/patches/gcc-xcode15-warnings.patch b/build/pkgs/gcc/patches/gcc-xcode15-warnings.patch deleted file mode 100644 index 5d1a8ca9160..00000000000 --- a/build/pkgs/gcc/patches/gcc-xcode15-warnings.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/gcc/config/aarch64/darwin.h b/gcc/config/aarch64/darwin.h -index 5609c569dc1..9fcbfa3d777 100644 ---- a/gcc/config/aarch64/darwin.h -+++ b/gcc/config/aarch64/darwin.h -@@ -65,10 +65,6 @@ along with GCC; see the file COPYING3. If not see - #define DARWIN_NOPIE_SPEC \ - " % Date: Wed, 31 Jul 2024 18:12:02 +0200 Subject: [PATCH 53/91] simplify conversion code in cubic Hecke --- .../hecke_algebras/cubic_hecke_base_ring.py | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py b/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py index 90d6657d309..fff3d59792d 100644 --- a/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py +++ b/src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py @@ -34,9 +34,9 @@ from sage.algebras.splitting_algebra import solve_with_extension, SplittingAlgebra -# --------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # local helper functions -# --------------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- def normalize_names_markov(names, markov_trace_version): r""" Return a tuple of strings of variable names of length 3 resp. 4 (if @@ -108,10 +108,10 @@ def register_ring_hom(ring_hom): return -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # class for the Galois Group action on the generic extension ring corresponding # to the cubic equation -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- class GaloisGroupAction(Action): r""" Action on a multivariate polynomial ring by permuting the generators. @@ -156,15 +156,15 @@ def _act_(self, perm, pol): return self.domain()(pol_dict) -################################################################################ +############################################################################### # EXTENSION RING -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- # Definition of the generic extension ring for the cubic Hecke algebra as # Laurent polynomial ring in 3 indeterminates over the cyclotomic field of a # third root of unity This is the most general ring over which the cubic Hecke # algebra is semi-simple. In opposite to the generic base ring class, this class # does not inherits from UniqueRepresentation since _test_pickling fails -# ------------------------------------------------------------------------------ +# ----------------------------------------------------------------------------- class CubicHeckeExtensionRing(LaurentPolynomialRing_mpair): r""" The generic splitting algebra for the irreducible representations of @@ -261,7 +261,6 @@ def __init__(self, names, order='degrevlex', ring_of_definition=None, third_unit # Init of data used on demand # ---------------------------------------------------------------------- self._mirror = None - return ############################################################################ # overloaded inherited methods @@ -410,12 +409,12 @@ def _an_element_(self): s = self.one() if rem: s = rem[0] - return b**2/c+a*e3/s + return b**2/c + a*e3/s ############################################################################ # local methods ############################################################################ - def _is_markov_trace_version(self): + def _is_markov_trace_version(self) -> bool: r""" Return whether ``self`` is the version containing the writhe parameter ``s`` for the Markov trace. @@ -437,39 +436,31 @@ def _is_markov_trace_version(self): # -------------------------------------------------------------------------- def _convert_from_gap3_mvp(self, mvp_expression): r""" - Convert a string produced via ``GAP3`` interface and containing Jean + Convert an element of ``GAP3`` interface containing Jean Michel's ``MVP`` (multivariate polynomials) to an element of ``self``. INPUT: - - ``string`` -- string produced via GAP3 interface and containing + - ``mvp_expression`` -- element of GAP3 interface containing Jean Michel's ``MVP`` (multivariate polynomials) EXAMPLES:: + sage: # optional - gap3 sage: from sage.algebras.hecke_algebras import cubic_hecke_base_ring as chbr + sage: CHA3 = algebras.CubicHecke(3) + sage: sch7 = CHA3.chevie().SchurElements()[7] sage: ER = chbr.CubicHeckeExtensionRing('a, b, c') - sage: gap3_string = '2+a^-2bc+a^-1b^-1c^2+a^-1b^2c^-1+ab^-2E3c' - sage: ER._convert_from_gap3_mvp(gap3_string) - a^-1*b^2*c^-1 + 2 + e3*a*b^-2*c + a^-2*b*c + a^-1*b^-1*c^2 + sage: ER._convert_from_gap3_mvp(sch7) + a*b*c^-2 + a^2*b^-1*c^-1 + a^-1*b^2*c^-1 + 2 + a*b^-2*c + a^-2*b*c + a^-1*b^-1*c^2 """ + from sage.misc.sage_eval import sage_eval E3 = self.cyclotomic_generator() a, b, c, *rem = self.gens() na, nb, nc = self.variable_names() - lc = {na: a, nb: b, nc: c, 'e': E3} - var_names = list(lc.keys()) - - from sage.repl.preparse import implicit_mul - # since implicit_mul does not know about the choice of variable names - # we have to insert * between them separately - string = str(mvp_expression) - string = string.replace('E3', 'e') - for i in var_names: - for j in var_names: - string = string.replace('%s%s' % (i, j), '%s*%s' % (i, j)) - sage_expression = implicit_mul(string) - from sage.misc.sage_eval import sage_eval - return sage_eval(sage_expression, locals=lc) + lc = {na: a, nb: b, nc: c, 'E3': E3} + sage_expr = str(mvp_expression.FormatMaple())[1:-1] + return sage_eval(sage_expr, locals=lc) ############################################################################ # global methods @@ -1062,7 +1053,7 @@ def _an_element_(self): ############################################################################ # Local Methods ############################################################################ - def _is_markov_trace_version(self): + def _is_markov_trace_version(self) -> bool: r""" Return whether ``self`` is the version containing the writhe parameter ``s`` for the Markov trace. From 5244b4d2881ee827cc797a5fefa9916209bf1380 Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Fri, 12 Jul 2024 13:49:32 +0200 Subject: [PATCH 54/91] support passing two base points to .log() for elliptic-curve points --- src/sage/schemes/elliptic_curves/ell_point.py | 109 +++++++++++++++++- 1 file changed, 106 insertions(+), 3 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 568d76ffc94..97f9b5a6ec4 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -3926,6 +3926,11 @@ def log(self, base): In other words, return an integer `x` such that `xP = Q` where `P` is ``base`` and `Q` is this point. + If ``base`` is a list or tuple of two points, then this function + solves a two-dimensional discrete logarithm: Given `(P_1,P_2)` in + ``base``, it returns a tuple of integers `(x,y)` such that + `[x]P_1 + [y]P_2 = Q`, where `Q` is this point. + A :class:`ValueError` is raised if there is no solution. ALGORITHM: @@ -3950,20 +3955,31 @@ def log(self, base): For anomalous curves with `\#E = p`, the :meth:`padic_elliptic_logarithm` function is called. + For two-dimensional logarithms, we first compute the Weil pairing of + `Q` with `P_1` and `P_2` and their logarithms to base the pairing of + `P_1` and `P_2`; this allows to read off `x` and `y` modulo the part + of the order where `P_1` and `P_2`. Modulo the rest of the order the + logarithm is effectively one-dimensional, so we can reduce the problem + to the basic one-dimensional case and finally recombine the results. + INPUT: - - ``base`` (point) -- another point on the same curve as ``self``. + - ``base`` (point, or list/tuple of two points) -- another point or + sequence of two points on the same curve as ``self``. OUTPUT: (integer) -- The discrete logarithm of `Q` with respect to `P`, which is an integer `x` with `0\le x<\mathrm{ord}(P)` such that - `xP=Q`, if one exists. + `xP=Q`, if one exists. In the case of two points `P_1,P_2`, two + integers `x,y` with `0\le x<\mathrm{ord}(P_1)` and + `0\le y<\mathrm{ord}(P_2)` such that `[x]P_1 + [y]P_2 = Q`. AUTHORS: - John Cremona. Adapted to use generic functions 2008-04-05. - Lorenz Panny (2022): switch to PARI. + - Lorenz Panny (2024): the two-dimensional case. EXAMPLES:: @@ -3978,6 +3994,16 @@ def log(self, base): sage: Q.log(P) 400 + :: + + sage: # needs sage.rings.finite_rings + sage: F = GF((5, 60), 'a') + sage: E = EllipticCurve(F, [1, 1]) + sage: P, Q = E.gens() + sage: T = 1234567890987654321*P + 1337*Q + sage: T.log([P, Q]) + (1234567890987654321, 1337) + TESTS: Some random testing:: @@ -3992,15 +4018,92 @@ def log(self, base): sage: x = Q.log(P) sage: x*P == Q True + + :: + + sage: # needs sage.rings.finite_rings + sage: sz = randint(16,24) + sage: e = randint(1,6) + sage: p = random_prime(ceil(2**(sz/e))) + sage: E = EllipticCurve(j=GF((p,e),'a').random_element()) + sage: E = choice(E.twists()) + sage: P = E.random_point() + sage: Q = E.random_point() + sage: T = randrange(2^99) * P + randrange(2^99) * Q + sage: x, y = T.log([P, Q]) + sage: 0 <= x < P.order() + True + sage: 0 <= y < Q.order() + True + sage: T == x*P + y*Q + True """ + # handle the two-dimensional case first + if isinstance(base, (list, tuple)): + if len(base) != 2: + raise ValueError('sequence must have length 2') + P1, P2 = base + if P1 not in self.parent() or P2 not in self.parent(): + raise ValueError('points do not lie on the same curve') + + n1 = P1.order() + n2 = P2.order() + n = n1.lcm(n2) + if not hasattr(self, '_order'): + if n * self: + raise ValueError('ECDLog problem has no solution (order does not divide order of base)') + self.set_order(multiple=n, check=False) + if not self.order().divides(n): + raise ValueError('ECDLog problem has no solution (order does not divide order of base)') + + # find the solution modulo the part where P1,P2 are independent + z = P1.weil_pairing(P2, n) + o = generic.order_from_multiple(z, n1.gcd(n2), operation='*') + if o.is_one(): + # workaround for PARI bug #2562 + x0, y0 = ZZ.zero(), ZZ.zero() + else: + v = self.weil_pairing(P2, n) + w = P1.weil_pairing(self, n) + try: + x0, y0 = v.log(z, o), w.log(z, o) + except TypeError: + # not all implementations of finite-field elements support passing the order in .log() + x0, y0 = v.log(z), w.log(z) + + T = self - x0*P1 - y0*P2 + if not T: + return x0, y0 + + from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper + try: + x1 = (n//n1 * T).log(o*P1, n1) + y1 = (n//n2 * T).log(o*P2, n2) + except TypeError: + # not all implementations of finite-field elements support passing the order in .log() + x1 = (n//n1 * T).log(o*P1) + y1 = (n//n2 * T).log(o*P2) + +# assert n//n1 * self == (x1*o + n//n1*x0) * P1 + n//n1*y0 * P2 +# assert n//n2 * self == n//n2*x0 * P1 + (y1*o + n//n2*y0) * P2 + + _,u,v = (n//n1).xgcd(n//n2) + assert _.is_one() + x = (u * (x1*o + n//n1*x0) + v * (n//n2*x0)) % n1 + y = (u * (n//n1*y0) + v * (y1*o + n//n2*y0)) % n2 + +# assert x*P1 + y*P2 == self + return x, y + if base not in self.parent(): raise ValueError('not a point on the same curve') n = base.order() - if n*self: + if (hasattr(self, '_order') and not self._order.divides(n)) or n*self: raise ValueError('ECDLog problem has no solution (order does not divide order of base)') E = self.curve() F = E.base_ring() p = F.cardinality() + if F.is_prime_field() and n == p: # Anomalous case return base.padic_elliptic_logarithm(self, p) From a8a46183224a4068566968cf5f6cd2f972651aea Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Fri, 12 Jul 2024 15:30:38 +0200 Subject: [PATCH 55/91] fix doctest (result is non-unique if P,Q are not independent) --- src/sage/schemes/elliptic_curves/ell_point.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 97f9b5a6ec4..a4ef98edde6 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -3999,7 +3999,9 @@ def log(self, base): sage: # needs sage.rings.finite_rings sage: F = GF((5, 60), 'a') sage: E = EllipticCurve(F, [1, 1]) - sage: P, Q = E.gens() + sage: E.abelian_group() + Additive abelian group isomorphic to Z/194301464603136995341424045476456938000 + Z/4464 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 5^60 + sage: P, Q = E.gens() # cached generators from .abelian_group() sage: T = 1234567890987654321*P + 1337*Q sage: T.log([P, Q]) (1234567890987654321, 1337) From 54747e59ea975ebabd23240243eaa97e0d3a292b Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Fri, 12 Jul 2024 15:42:24 +0200 Subject: [PATCH 56/91] slightly more documentation re: workarounds for known bugs --- src/sage/schemes/elliptic_curves/ell_point.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index a4ef98edde6..42dadeb4e13 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -4062,7 +4062,7 @@ def log(self, base): z = P1.weil_pairing(P2, n) o = generic.order_from_multiple(z, n1.gcd(n2), operation='*') if o.is_one(): - # workaround for PARI bug #2562 + # slight optimization, but also workaround for PARI bug #2562 x0, y0 = ZZ.zero(), ZZ.zero() else: v = self.weil_pairing(P2, n) @@ -4071,6 +4071,7 @@ def log(self, base): x0, y0 = v.log(z, o), w.log(z, o) except TypeError: # not all implementations of finite-field elements support passing the order in .log() + # known bug -- fixing #38350 will eliminate the need for this try-except x0, y0 = v.log(z), w.log(z) T = self - x0*P1 - y0*P2 @@ -4083,6 +4084,7 @@ def log(self, base): y1 = (n//n2 * T).log(o*P2, n2) except TypeError: # not all implementations of finite-field elements support passing the order in .log() + # known bug -- fixing #38350 will eliminate the need for this try-except x1 = (n//n1 * T).log(o*P1) y1 = (n//n2 * T).log(o*P2) From 540358a82548d4ea84890d5816dd3cc665f92b87 Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Fri, 12 Jul 2024 18:18:57 +0200 Subject: [PATCH 57/91] also support sequences of lengths 0 and 1 in .log() --- src/sage/schemes/elliptic_curves/ell_point.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 42dadeb4e13..9b7f010fc20 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -4042,14 +4042,18 @@ def log(self, base): """ # handle the two-dimensional case first if isinstance(base, (list, tuple)): - if len(base) != 2: - raise ValueError('sequence must have length 2') + if not base: + return self.log(self.curve().zero()) + elif len(base) == 1: + return self.log(base[0]) + elif len(base) > 2: + raise ValueError('sequence must have length <= 2') + P1, P2 = base if P1 not in self.parent() or P2 not in self.parent(): raise ValueError('points do not lie on the same curve') - n1 = P1.order() - n2 = P2.order() + n1, n2 = P1.order(), P2.order() n = n1.lcm(n2) if not hasattr(self, '_order'): if n * self: From 7c1d2e66f2a1dcbafa75cf1835643fb4fa1bc52c Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Tue, 16 Jul 2024 15:55:40 +0200 Subject: [PATCH 58/91] remove unused import --- src/sage/schemes/elliptic_curves/ell_point.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 9b7f010fc20..cf33d9c1560 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -4082,7 +4082,6 @@ def log(self, base): if not T: return x0, y0 - from sage.groups.additive_abelian.additive_abelian_wrapper import AdditiveAbelianGroupWrapper try: x1 = (n//n1 * T).log(o*P1, n1) y1 = (n//n2 * T).log(o*P2, n2) From 1e565bc8e36fce6829aafdafb224bfb022a445c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Thu, 1 Aug 2024 13:57:21 +0200 Subject: [PATCH 59/91] some details --- src/sage/symbolic/expression_conversions.py | 47 +++++++++++---------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 1fbad090aa4..ba0ed44ac72 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -32,7 +32,7 @@ lazy_import('sage.symbolic.expression_conversion_algebraic', ['AlgebraicConverter', 'algebraic']) -class FakeExpression(): +class FakeExpression: r""" Pynac represents `x/y` as `xy^{-1}`. Often, tree-walkers would prefer to see divisions instead of multiplications and negative exponents. @@ -130,7 +130,7 @@ def _fast_callable_(self, etb): return fast_callable(self, etb) -class Converter(): +class Converter: def __init__(self, use_fake_div=False): """ If use_fake_div is set to True, then the converter will try to @@ -1425,7 +1425,7 @@ def arithmetic(self, ex, operator): from sage.rings.rational import Rational base, expt = operands - if expt == Rational(((1, 2))): + if expt == Rational((1, 2)): from sage.misc.functional import sqrt return sqrt(self(base)) try: @@ -1661,13 +1661,13 @@ class Exponentialize(ExpressionTreeWalker): # Implementation note: this code is executed once at first # reference in the code using it, therefore avoiding rebuilding # the same canned results dictionary at each call. + from sage.calculus.var import function from sage.functions.hyperbolic import sinh, cosh, sech, csch, tanh, coth from sage.functions.log import exp from sage.functions.trig import sin, cos, sec, csc, tan, cot - from sage.symbolic.constants import e, I from sage.rings.integer import Integer + from sage.symbolic.constants import e, I from sage.symbolic.ring import SR - from sage.calculus.var import function half = Integer(1) / Integer(2) two = Integer(2) x = SR.var("x") @@ -1685,7 +1685,7 @@ class Exponentialize(ExpressionTreeWalker): tanh: (-(exp(-x) - exp(x))/(exp(x) + exp(-x))).function(x), coth: (-(exp(-x) + exp(x))/(exp(-x) - exp(x))).function(x) } - Circs = list(CircDict.keys()) + Circs = list(CircDict) def __init__(self, ex): """ @@ -1795,35 +1795,38 @@ class HalfAngle(ExpressionTreeWalker): of half the original argument. """ # Code executed once at first class reference: create canned formulae. + from sage.calculus.var import function from sage.functions.hyperbolic import sinh, cosh, sech, csch, tanh, coth from sage.functions.trig import sin, cos, sec, csc, tan, cot from sage.rings.integer import Integer - from sage.calculus.var import function from sage.symbolic.ring import SR x = SR.var("x") one = Integer(1) two = Integer(2) - half = one/two + half = one / two + halfx = half * x HalvesDict = { - sin: two*tan(half*x)/(tan(half*x)**2 + one).function(x), - cos: -(tan(half*x)**2 - one)/(tan(half*x)**2 + one).function(x), - tan: -two*tan(half*x)/(tan(half*x)**2 - one).function(x), - csc: half*(tan(half*x)**2 + one)/tan(half*x).function(x), - sec: -(tan(half*x)**2 + one)/(tan(half*x)**2 - one).function(x), - cot: -half*(tan(half*x)**2 - one)/tan(half*x).function(x), - sinh: -two*tanh(half*x)/(tanh(half*x)**2 - one).function(x), - cosh: -(tanh(half*x)**2 + one)/(tanh(half*x)**2 - one).function(x), - tanh: two*tanh(half*x)/(tanh(half*x)**2 + one).function(x), - csch: -half*(tanh(half*x)**2 - one)/tanh(half*x).function(x), - sech: -(tanh(half*x)**2 - one)/(tanh(half*x)**2 + one).function(x), - coth: half*(tanh(half*x)**2 + one)/tanh(half*x).function(x) + sin: two * tan(halfx) / (tan(halfx)**2 + one).function(x), + cos: -(tan(halfx)**2 - one) / (tan(halfx)**2 + one).function(x), + tan: -two * tan(halfx) / (tan(halfx)**2 - one).function(x), + csc: half * (tan(halfx)**2 + one) / tan(halfx).function(x), + sec: -(tan(halfx)**2 + one) / (tan(halfx)**2 - one).function(x), + cot: -half * (tan(halfx)**2 - one) / tan(halfx).function(x), + sinh: -two * tanh(halfx) / (tanh(halfx)**2 - one).function(x), + cosh: -(tanh(halfx)**2 + one) / (tanh(halfx)**2 - one).function(x), + tanh: two * tanh(halfx) / (tanh(halfx)**2 + one).function(x), + csch: -half * (tanh(halfx)**2 - one) / tanh(halfx).function(x), + sech: -(tanh(halfx)**2 - one) / (tanh(halfx)**2 + one).function(x), + coth: half * (tanh(halfx)**2 + one) / tanh(halfx).function(x) } Halves = list(HalvesDict) + def __init__(self, ex): """ Initialize. """ self.ex = ex + def composition(self, ex, op): """ Compose. @@ -1838,7 +1841,7 @@ def composition(self, ex, op): """ if op in self.Halves: return self.HalvesDict.get(op)(*[self(x) for x in ex.operands()]) - return super(HalfAngle, self).composition(ex, op) + return super().composition(ex, op) class HoldRemover(ExpressionTreeWalker): @@ -1885,8 +1888,8 @@ def composition(self, ex, operator): sage: h() 0 """ - from sage.functions.other import Function_sum, Function_prod from sage.calculus.calculus import symbolic_sum, symbolic_product + from sage.functions.other import Function_sum, Function_prod if not operator: return self if isinstance(operator, Function_sum): From 3d0533d13ca0c50a43f41b7aa5d4d9684899aec2 Mon Sep 17 00:00:00 2001 From: Aaron Dwyer <109538917+aadwyer@users.noreply.github.com> Date: Thu, 1 Aug 2024 18:54:53 -0400 Subject: [PATCH 60/91] Update src/sage/combinat/designs/covering_array.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Köppe --- src/sage/combinat/designs/covering_array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index f956f9808f9..43a7a846757 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -260,7 +260,7 @@ def covering_array(strength, number_columns, levels): if in_database: return in_database - if orthogonal_array(number_columns, levels, strength, existence=True) == True: + if orthogonal_array(number_columns, levels, strength, existence=True) is True: return orthogonal_array(number_columns, levels, strength) else: From b9dbbb54b86ef39d6f324e998a71b8bb38bbbaeb Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Fri, 2 Aug 2024 01:00:46 +0200 Subject: [PATCH 61/91] remove workaround for #38350 since #38359 seems to be happening --- src/sage/schemes/elliptic_curves/ell_point.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index cf33d9c1560..676b71b5813 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -4071,25 +4071,18 @@ def log(self, base): else: v = self.weil_pairing(P2, n) w = P1.weil_pairing(self, n) - try: - x0, y0 = v.log(z, o), w.log(z, o) - except TypeError: - # not all implementations of finite-field elements support passing the order in .log() - # known bug -- fixing #38350 will eliminate the need for this try-except - x0, y0 = v.log(z), w.log(z) + x0, y0 = v.log(z, o), w.log(z, o) T = self - x0*P1 - y0*P2 if not T: return x0, y0 - try: - x1 = (n//n1 * T).log(o*P1, n1) - y1 = (n//n2 * T).log(o*P2, n2) - except TypeError: - # not all implementations of finite-field elements support passing the order in .log() - # known bug -- fixing #38350 will eliminate the need for this try-except - x1 = (n//n1 * T).log(o*P1) - y1 = (n//n2 * T).log(o*P2) + T1 = n//n1 * T + T2 = n//n2 * T + T1.set_order(multiple=n1, check=False) + T2.set_order(multiple=n2, check=False) + x1 = T1.log(o*P1) + y1 = T2.log(o*P2) # assert n//n1 * self == (x1*o + n//n1*x0) * P1 + n//n1*y0 * P2 # assert n//n2 * self == n//n2*x0 * P1 + (y1*o + n//n2*y0) * P2 From 1cca0f6e125386a9c2a0e3f121d8c6746c4c8f21 Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sat, 27 Jul 2024 13:59:00 +0200 Subject: [PATCH 62/91] Make # abs tol compare over the complex numbers For calculations over complex numbers that generate numeric noise, one tends to create small but non-zero imaginary parts. This PR updates the "# abs tol" tolerance setting to work over the complex numbers, as the "abs" suggests complex numbers. The real and imaginary parts are compared separately. The ordinary "# tol" and "# rel tol" are left as is. Fixes #36631 --- .../known-test-failures.json | 14 +- src/sage/doctest/check_tolerance.py | 259 ++++++++++++++++++ src/sage/doctest/control.py | 5 +- src/sage/doctest/marked_output.py | 102 +++++++ src/sage/doctest/parsing.py | 227 ++------------- src/sage/doctest/rif_tol.py | 123 +++++++++ 6 files changed, 524 insertions(+), 206 deletions(-) create mode 100644 src/sage/doctest/check_tolerance.py create mode 100644 src/sage/doctest/marked_output.py create mode 100644 src/sage/doctest/rif_tol.py diff --git a/pkgs/sagemath-categories/known-test-failures.json b/pkgs/sagemath-categories/known-test-failures.json index 80705635b7e..23e9f1adeeb 100644 --- a/pkgs/sagemath-categories/known-test-failures.json +++ b/pkgs/sagemath-categories/known-test-failures.json @@ -807,6 +807,10 @@ "failed": true, "ntests": 0 }, + "sage.doctest.check_tolerance": { + "failed": true, + "ntests": 19 + }, "sage.doctest.control": { "failed": true, "ntests": 230 @@ -821,13 +825,21 @@ "failed": true, "ntests": 413 }, + "sage.doctest.marked_output": { + "failed": true, + "ntests": 21 + }, "sage.doctest.parsing": { "failed": true, - "ntests": 313 + "ntests": 275 }, "sage.doctest.reporting": { "ntests": 115 }, + "sage.doctest.rif_tol": { + "failed": true, + "ntests": 18 + }, "sage.doctest.sources": { "failed": true, "ntests": 343 diff --git a/src/sage/doctest/check_tolerance.py b/src/sage/doctest/check_tolerance.py new file mode 100644 index 00000000000..356369151aa --- /dev/null +++ b/src/sage/doctest/check_tolerance.py @@ -0,0 +1,259 @@ +# sage_setup: distribution = sagemath-repl +""" +Check tolerance when parsing docstrings +""" + +# **************************************************************************** +# Copyright (C) 2012-2018 David Roe +# 2012 Robert Bradshaw +# 2012 William Stein +# 2013 R. Andrew Ohana +# 2013 Volker Braun +# 2013-2018 Jeroen Demeyer +# 2016-2021 Frédéric Chapoton +# 2017-2018 Erik M. Bray +# 2020 Marc Mezzarobba +# 2020-2023 Matthias Koeppe +# 2022 John H. Palmieri +# 2022 Sébastien Labbé +# 2023 Kwankyu Lee +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# https://www.gnu.org/licenses/ +# **************************************************************************** + +import re +from sage.doctest.rif_tol import RIFtol, add_tolerance +from sage.doctest.marked_output import MarkedOutput + + +# Regex pattern for float without the (optional) leading sign +float_without_sign = r'((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?' + + +# Regular expression for floats +float_regex = re.compile(r'\s*([+-]?\s*' + float_without_sign + r')') + + +class ToleranceExceededError(BaseException): + pass + + +def check_tolerance_real_domain(want: MarkedOutput, got: str) -> tuple[str, str]: + """ + Compare want and got over real domain with tolerance + + INPUT: + + - ``want`` -- a string, what you want + - ``got`` -- a string, what you got + + OUTPUT: + + The strings to compare, but with matching float numbers replaced by asterisk. + + EXAMPLES:: + + sage: from sage.doctest.check_tolerance import check_tolerance_real_domain + sage: from sage.doctest.marked_output import MarkedOutput + sage: check_tolerance_real_domain( + ....: MarkedOutput('foo:0.2').update(abs_tol=0.3), + ....: 'bar:0.4') + ['foo:*', 'bar:*'] + sage: check_tolerance_real_domain( + ....: MarkedOutput('foo:0.2').update(abs_tol=0.3), + ....: 'bar:0.6') + Traceback (most recent call last): + ... + sage.doctest.check_tolerance.ToleranceExceededError + """ + # First check that the number of occurrences of floats appearing match + want_str = [g[0] for g in float_regex.findall(want)] + got_str = [g[0] for g in float_regex.findall(got)] + if len(want_str) != len(got_str): + raise ToleranceExceededError() + + # Then check the numbers + want_values = [RIFtol(g) for g in want_str] + want_intervals = [add_tolerance(v, want) for v in want_values] + got_values = [RIFtol(g) for g in got_str] + # The doctest is not successful if one of the "want" and "got" + # intervals have an empty intersection + if not all(a.overlaps(b) for a, b in zip(want_intervals, got_values)): + raise ToleranceExceededError() + + # Then check the part of the doctests without the numbers + # Continue the check process with floats replaced by stars + want = float_regex.sub('*', want) + got = float_regex.sub('*', got) + return [want, got] + + +# match 1.0 or 1.0 + I or 1.0 + 2.0*I +real_plus_optional_imag = ''.join([ + r'\s*(?P[+-]?\s*', + float_without_sign, + r')(\s*(?P[+-]\s*', + float_without_sign, + r')\*I|\s*(?P[+-])\s*I)?', +]) + + +# match - 2.0*I +only_imag = ''.join([ + r'\s*(?P[+-]?\s*', + float_without_sign, + r')\*I', +]) + + +# match I or -I (no digits), require a non-word part before and after for specificity +imaginary_unit = r'(?P^|\W)(?P[+-]?)I(?P$|\W)' + + +complex_regex = re.compile(''.join([ + '(', + only_imag, + '|', + imaginary_unit, + '|', + real_plus_optional_imag, + ')', +])) + + +def complex_match_to_real_and_imag(m: re.Match) -> tuple[str, str]: + """ + Extract real and imaginary part from match + + INPUT: + + - ``m`` -- match from ``complex_regex`` + + OUTPUT: + + Pair of real and complex parts (as string) + + EXAMPLES:: + + sage: from sage.doctest.check_tolerance import complex_match_to_real_and_imag, complex_regex + sage: complex_match_to_real_and_imag(complex_regex.match('1.0')) + ('1.0', '0') + sage: complex_match_to_real_and_imag(complex_regex.match('-1.0 - I')) + ('-1.0', '-1') + sage: complex_match_to_real_and_imag(complex_regex.match('1.0 - 3.0*I')) + ('1.0', '- 3.0') + sage: complex_match_to_real_and_imag(complex_regex.match('1.0*I')) + ('0', '1.0') + sage: complex_match_to_real_and_imag(complex_regex.match('- 2.0*I')) + ('0', '- 2.0') + sage: complex_match_to_real_and_imag(complex_regex.match('-I')) + ('0', '-1') + sage: for match in complex_regex.finditer('[1, -1, I, -1, -I]'): + ....: print(complex_match_to_real_and_imag(match)) + ('1', '0') + ('-1', '0') + ('0', '1') + ('-1', '0') + ('0', '-1') + sage: for match in complex_regex.finditer('[1, -1.3, -1.5 + 0.1*I, 0.5 - 0.1*I, -1.5*I]'): + ....: print(complex_match_to_real_and_imag(match)) + ('1', '0') + ('-1.3', '0') + ('-1.5', '+ 0.1') + ('0.5', '- 0.1') + ('0', '-1.5') + """ + real = m.group('real') + if real is not None: + real_imag_coeff = m.group('real_imag_coeff') + real_imag_unit = m.group('real_imag_unit') + if real_imag_coeff is not None: + return (real, real_imag_coeff) + elif real_imag_unit is not None: + return (real, real_imag_unit + '1') + else: + return (real, '0') + only_imag = m.group('only_imag') + if only_imag is not None: + return ('0', only_imag) + unit_imag = m.group('unit_imag') + if unit_imag is not None: + return ('0', unit_imag + '1') + assert False, 'unreachable' + + +def complex_star_repl(m: re.Match): + """ + Replace the complex number in the match with '*' + """ + if m.group('unit_imag') is not None: + # preserve the matched non-word part + return ''.join([ + (m.group('unit_imag_pre') or '').strip(), + '*', + (m.group('unit_imag_post') or '').strip(), + ]) + else: + return '*' + + +def check_tolerance_complex_domain(want: MarkedOutput, got: str) -> tuple[str, str]: + """ + Compare want and got over complex domain with tolerance + + INPUT: + + - ``want`` -- a string, what you want + - ``got`` -- a string, what you got + + OUTPUT: + + The strings to compare, but with matching complex numbers replaced by asterisk. + + EXAMPLES:: + + sage: from sage.doctest.check_tolerance import check_tolerance_complex_domain + sage: from sage.doctest.marked_output import MarkedOutput + sage: check_tolerance_complex_domain( + ....: MarkedOutput('foo:[0.2 + 0.1*I]').update(abs_tol=0.3), + ....: 'bar:[0.4]') + ['foo:[*]', 'bar:[*]'] + sage: check_tolerance_complex_domain( + ....: MarkedOutput('foo:-0.5 - 0.1*I').update(abs_tol=2), + ....: 'bar:1') + ['foo:*', 'bar:*'] + sage: check_tolerance_complex_domain( + ....: MarkedOutput('foo:[1.0*I]').update(abs_tol=0.3), + ....: 'bar:[I]') + ['foo:[*]', 'bar:[*]'] + sage: check_tolerance_complex_domain(MarkedOutput('foo:0.2 + 0.1*I').update(abs_tol=0.3), 'bar:0.6') + Traceback (most recent call last): + ... + sage.doctest.check_tolerance.ToleranceExceededError + """ + want_str = [] + for match in complex_regex.finditer(want): + want_str.extend(complex_match_to_real_and_imag(match)) + got_str = [] + for match in complex_regex.finditer(got): + got_str.extend(complex_match_to_real_and_imag(match)) + if len(want_str) != len(got_str): + raise ToleranceExceededError() + + # Then check the numbers + want_values = [RIFtol(g) for g in want_str] + want_intervals = [add_tolerance(v, want) for v in want_values] + got_values = [RIFtol(g) for g in got_str] + # The doctest is not successful if one of the "want" and "got" + # intervals have an empty intersection + if not all(a.overlaps(b) for a, b in zip(want_intervals, got_values)): + raise ToleranceExceededError() + + # Then check the part of the doctests without the numbers + # Continue the check process with floats replaced by stars + want = complex_regex.sub(complex_star_repl, want) + got = complex_regex.sub(complex_star_repl, got) + return [want, got] diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index 4908959e497..34c7e1299c5 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -970,7 +970,7 @@ def expand_files_into_sources(self): sage: DC = DocTestController(DD, [dirname]) sage: DC.expand_files_into_sources() sage: len(DC.sources) - 12 + 15 sage: DC.sources[0].options.optional True @@ -1071,13 +1071,16 @@ def sort_sources(self): sage.doctest.util sage.doctest.test sage.doctest.sources + sage.doctest.rif_tol sage.doctest.reporting sage.doctest.parsing_test sage.doctest.parsing + sage.doctest.marked_output sage.doctest.forker sage.doctest.fixtures sage.doctest.external sage.doctest.control + sage.doctest.check_tolerance sage.doctest.all sage.doctest """ diff --git a/src/sage/doctest/marked_output.py b/src/sage/doctest/marked_output.py new file mode 100644 index 00000000000..e2f08443ea7 --- /dev/null +++ b/src/sage/doctest/marked_output.py @@ -0,0 +1,102 @@ +# sage_setup: distribution = sagemath-repl +""" +Helper for attaching tolerance information to strings +""" + +# **************************************************************************** +# Copyright (C) 2012-2018 David Roe +# 2012 Robert Bradshaw +# 2012 William Stein +# 2013 R. Andrew Ohana +# 2013 Volker Braun +# 2013-2018 Jeroen Demeyer +# 2016-2021 Frédéric Chapoton +# 2017-2018 Erik M. Bray +# 2020 Marc Mezzarobba +# 2020-2023 Matthias Koeppe +# 2022 John H. Palmieri +# 2022 Sébastien Labbé +# 2023 Kwankyu Lee +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# https://www.gnu.org/licenses/ +# **************************************************************************** + + +class MarkedOutput(str): + """ + A subclass of string with context for whether another string + matches it. + + EXAMPLES:: + + sage: from sage.doctest.marked_output import MarkedOutput + sage: s = MarkedOutput("abc") + sage: s.rel_tol + 0 + sage: s.update(rel_tol = .05) + 'abc' + sage: s.rel_tol + 0.0500000000000000 + + sage: MarkedOutput("56 µs") + '56 \xb5s' + """ + random = False + rel_tol = 0 + abs_tol = 0 + tol = 0 + + def update(self, **kwds): + """ + EXAMPLES:: + + sage: from sage.doctest.marked_output import MarkedOutput + sage: s = MarkedOutput("0.0007401") + sage: s.update(abs_tol = .0000001) + '0.0007401' + sage: s.rel_tol + 0 + sage: s.abs_tol + 1.00000000000000e-7 + """ + self.__dict__.update(kwds) + return self + + def __reduce__(self): + """ + Pickling. + + EXAMPLES:: + + sage: from sage.doctest.marked_output import MarkedOutput + sage: s = MarkedOutput("0.0007401") + sage: s.update(abs_tol = .0000001) + '0.0007401' + sage: t = loads(dumps(s)) # indirect doctest + sage: t == s + True + sage: t.abs_tol + 1.00000000000000e-7 + """ + return make_marked_output, (str(self), self.__dict__) + + +def make_marked_output(s, D): + """ + Auxiliary function for pickling. + + EXAMPLES:: + + sage: from sage.doctest.marked_output import make_marked_output + sage: s = make_marked_output("0.0007401", {'abs_tol':.0000001}) + sage: s + '0.0007401' + sage: s.abs_tol + 1.00000000000000e-7 + """ + ans = MarkedOutput(s) + ans.__dict__.update(D) + return ans diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index 92dd31384b3..d9b054ae2dd 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -43,53 +43,14 @@ from sage.misc.cachefunc import cached_function from sage.repl.preparse import preparse, strip_string_literals +from sage.doctest.rif_tol import RIFtol, add_tolerance +from sage.doctest.marked_output import MarkedOutput +from sage.doctest.check_tolerance import ( + ToleranceExceededError, check_tolerance_real_domain, + check_tolerance_complex_domain, float_regex) from .external import available_software, external_software -_RIFtol = None - - -def RIFtol(*args): - """ - Create an element of the real interval field used for doctest tolerances. - - It allows large numbers like 1e1000, it parses strings with spaces - like ``RIF(" - 1 ")`` out of the box and it carries a lot of - precision. The latter is useful for testing libraries using - arbitrary precision but not guaranteed rounding such as PARI. We use - 1044 bits of precision, which should be good to deal with tolerances - on numbers computed with 1024 bits of precision. - - The interval approach also means that we do not need to worry about - rounding errors and it is also very natural to see a number with - tolerance as an interval. - - EXAMPLES:: - - sage: from sage.doctest.parsing import RIFtol - sage: RIFtol(-1, 1) - 0.? - sage: RIFtol(" - 1 ") - -1 - sage: RIFtol("1e1000") - 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000?e1000 - """ - global _RIFtol - if _RIFtol is None: - try: - # We need to import from sage.all to avoid circular imports. - from sage.rings.real_mpfi import RealIntervalField - except ImportError: - from warnings import warn - warn("RealIntervalField not available, ignoring all tolerance specifications in doctests") - - def fake_RIFtol(*args): - return 0 - _RIFtol = fake_RIFtol - else: - _RIFtol = RealIntervalField(1044) - return _RIFtol(*args) - # This is the correct pattern to match ISO/IEC 6429 ANSI escape sequences: ansi_escape_sequence = re.compile(r"(\x1b[@-Z\\-~]|\x1b\[.*?[@-~]|\x9b.*?[@-~])") @@ -691,83 +652,6 @@ def reduce_hex(fingerprints): return "%032x" % res -class MarkedOutput(str): - """ - A subclass of string with context for whether another string - matches it. - - EXAMPLES:: - - sage: from sage.doctest.parsing import MarkedOutput - sage: s = MarkedOutput("abc") - sage: s.rel_tol - 0 - sage: s.update(rel_tol = .05) - 'abc' - sage: s.rel_tol - 0.0500000000000000 - - sage: MarkedOutput("56 µs") - '56 \xb5s' - """ - random = False - rel_tol = 0 - abs_tol = 0 - tol = 0 - - def update(self, **kwds): - """ - EXAMPLES:: - - sage: from sage.doctest.parsing import MarkedOutput - sage: s = MarkedOutput("0.0007401") - sage: s.update(abs_tol = .0000001) - '0.0007401' - sage: s.rel_tol - 0 - sage: s.abs_tol - 1.00000000000000e-7 - """ - self.__dict__.update(kwds) - return self - - def __reduce__(self): - """ - Pickling. - - EXAMPLES:: - - sage: from sage.doctest.parsing import MarkedOutput - sage: s = MarkedOutput("0.0007401") - sage: s.update(abs_tol = .0000001) - '0.0007401' - sage: t = loads(dumps(s)) # indirect doctest - sage: t == s - True - sage: t.abs_tol - 1.00000000000000e-7 - """ - return make_marked_output, (str(self), self.__dict__) - - -def make_marked_output(s, D): - """ - Auxiliary function for pickling. - - EXAMPLES:: - - sage: from sage.doctest.parsing import make_marked_output - sage: s = make_marked_output("0.0007401", {'abs_tol':.0000001}) - sage: s - '0.0007401' - sage: s.abs_tol - 1.00000000000000e-7 - """ - ans = MarkedOutput(s) - ans.__dict__.update(D) - return ans - - class OriginalSource(): r""" Context swapping out the pre-parsed source with the original for @@ -985,7 +869,7 @@ def parse(self, string, *args): sage: ex.want '0.893515349287690\n' sage: type(ex.want) - + sage: ex.want.tol 2.000000000000000000...?e-11 @@ -1323,7 +1207,7 @@ class SageOutputChecker(doctest.OutputChecker): sage: ex.want '0.893515349287690\n' sage: type(ex.want) - + sage: ex.want.tol 2.000000000000000000...?e-11 sage: OC.check_output(ex.want, '0.893515349287690', optflag) @@ -1363,56 +1247,6 @@ def human_readable(match): return '' return ansi_escape_sequence.subn(human_readable, string)[0] - def add_tolerance(self, wantval, want): - """ - Enlarge the real interval element ``wantval`` according to - the tolerance options in ``want``. - - INPUT: - - - ``wantval`` -- a real interval element - - ``want`` -- a :class:`MarkedOutput` describing the tolerance - - OUTPUT: an interval element containing ``wantval`` - - EXAMPLES:: - - sage: from sage.doctest.parsing import MarkedOutput, SageOutputChecker - sage: OC = SageOutputChecker() - sage: want_tol = MarkedOutput().update(tol=0.0001) - sage: want_abs = MarkedOutput().update(abs_tol=0.0001) - sage: want_rel = MarkedOutput().update(rel_tol=0.0001) - sage: OC.add_tolerance(RIF(pi.n(64)), want_tol).endpoints() # needs sage.symbolic - (3.14127849432443, 3.14190681285516) - sage: OC.add_tolerance(RIF(pi.n(64)), want_abs).endpoints() # needs sage.symbolic - (3.14149265358979, 3.14169265358980) - sage: OC.add_tolerance(RIF(pi.n(64)), want_rel).endpoints() # needs sage.symbolic - (3.14127849432443, 3.14190681285516) - sage: OC.add_tolerance(RIF(1e1000), want_tol) - 1.000?e1000 - sage: OC.add_tolerance(RIF(1e1000), want_abs) - 1.000000000000000?e1000 - sage: OC.add_tolerance(RIF(1e1000), want_rel) - 1.000?e1000 - sage: OC.add_tolerance(0, want_tol) - 0.000? - sage: OC.add_tolerance(0, want_abs) - 0.000? - sage: OC.add_tolerance(0, want_rel) - 0 - """ - if want.tol: - if wantval == 0: - return RIFtol(want.tol) * RIFtol(-1, 1) - else: - return wantval * (1 + RIFtol(want.tol) * RIFtol(-1, 1)) - elif want.abs_tol: - return wantval + RIFtol(want.abs_tol) * RIFtol(-1, 1) - elif want.rel_tol: - return wantval * (1 + RIFtol(want.rel_tol) * RIFtol(-1, 1)) - else: - return wantval - def check_output(self, want, got, optionflags): r""" Check to see if the output matches the desired output. @@ -1509,6 +1343,11 @@ def check_output(self, want, got, optionflags): sage: 0 # rel tol 1 1 + Abs tol checks over the complex domain:: + + sage: [1, -1.3, -1.5 + 0.1*I, 0.5 - 0.1*I, -1.5*I] # abs tol 1.0 + [1, -1, -1, 1, -I] + Spaces before numbers or between the sign and number are ignored:: sage: print("[ - 1, 2]") # abs tol 1e-10 @@ -1539,34 +1378,17 @@ def check_output(self, want, got, optionflags): sage: OC.check_output(ex.want, 'Long-step dual simplex will be used\n1.3090169943749475', optflag) True """ - # Regular expression for floats - float_regex = re.compile(r'\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)') - got = self.human_readable_escape_sequences(got) - - if isinstance(want, MarkedOutput): - if want.random: - return True - elif want.tol or want.rel_tol or want.abs_tol: - # First check that the number of occurrences of floats appearing match - want_str = [g[0] for g in float_regex.findall(want)] - got_str = [g[0] for g in float_regex.findall(got)] - if len(want_str) != len(got_str): - return False - - # Then check the numbers - want_values = [RIFtol(g) for g in want_str] - want_intervals = [self.add_tolerance(v, want) for v in want_values] - got_values = [RIFtol(g) for g in got_str] - # The doctest is not successful if one of the "want" and "got" - # intervals have an empty intersection - if not all(a.overlaps(b) for a, b in zip(want_intervals, got_values)): - return False - - # Then check the part of the doctests without the numbers - # Continue the check process with floats replaced by stars - want = float_regex.sub('*', want) - got = float_regex.sub('*', got) + try: + if isinstance(want, MarkedOutput): + if want.random: + return True + elif want.tol or want.rel_tol: + want, got = check_tolerance_real_domain(want, got) + elif want.abs_tol: + want, got = check_tolerance_complex_domain(want, got) + except ToleranceExceededError: + return False if doctest.OutputChecker.check_output(self, want, got, optionflags): return True @@ -1823,9 +1645,6 @@ def output_difference(self, example, got, optionflags): Tolerance exceeded: 0.0 vs 10.05, tolerance +infinity > 1e-1 """ - # Regular expression for floats - float_regex = re.compile(r'\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)') - got = self.human_readable_escape_sequences(got) want = example.want diff = doctest.OutputChecker.output_difference(self, example, got, optionflags) @@ -1847,7 +1666,7 @@ def fail(x, y, actual, desired): for wstr, gstr in zip(want_str, got_str): w = RIFtol(wstr) g = RIFtol(gstr) - if not g.overlaps(self.add_tolerance(w, want)): + if not g.overlaps(add_tolerance(w, want)): if want.tol: if not w: fail(wstr, gstr, abs(g), want.tol) diff --git a/src/sage/doctest/rif_tol.py b/src/sage/doctest/rif_tol.py new file mode 100644 index 00000000000..619b2e500cd --- /dev/null +++ b/src/sage/doctest/rif_tol.py @@ -0,0 +1,123 @@ +# sage_setup: distribution = sagemath-repl +""" +Helpers for tolerance checking in doctests +""" + +# **************************************************************************** +# Copyright (C) 2012-2018 David Roe +# 2012 Robert Bradshaw +# 2012 William Stein +# 2013 R. Andrew Ohana +# 2013 Volker Braun +# 2013-2018 Jeroen Demeyer +# 2016-2021 Frédéric Chapoton +# 2017-2018 Erik M. Bray +# 2020 Marc Mezzarobba +# 2020-2023 Matthias Koeppe +# 2022 John H. Palmieri +# 2022 Sébastien Labbé +# 2023 Kwankyu Lee +# +# Distributed under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# https://www.gnu.org/licenses/ +# **************************************************************************** + +from sage.doctest.marked_output import MarkedOutput + + +_RIFtol = None + + +def RIFtol(*args): + """ + Create an element of the real interval field used for doctest tolerances. + + It allows large numbers like 1e1000, it parses strings with spaces + like ``RIF(" - 1 ")`` out of the box and it carries a lot of + precision. The latter is useful for testing libraries using + arbitrary precision but not guaranteed rounding such as PARI. We use + 1044 bits of precision, which should be good to deal with tolerances + on numbers computed with 1024 bits of precision. + + The interval approach also means that we do not need to worry about + rounding errors and it is also very natural to see a number with + tolerance as an interval. + + EXAMPLES:: + + sage: from sage.doctest.parsing import RIFtol + sage: RIFtol(-1, 1) + 0.? + sage: RIFtol(" - 1 ") + -1 + sage: RIFtol("1e1000") + 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000?e1000 + """ + global _RIFtol + if _RIFtol is None: + try: + # We need to import from sage.all to avoid circular imports. + from sage.rings.real_mpfi import RealIntervalField + except ImportError: + from warnings import warn + warn("RealIntervalField not available, ignoring all tolerance specifications in doctests") + + def fake_RIFtol(*args): + return 0 + _RIFtol = fake_RIFtol + else: + _RIFtol = RealIntervalField(1044) + return _RIFtol(*args) + + +def add_tolerance(wantval, want: MarkedOutput): + """ + Enlarge the real interval element ``wantval`` according to + the tolerance options in ``want``. + + INPUT: + + - ``wantval`` -- a real interval element + - ``want`` -- a :class:`MarkedOutput` describing the tolerance + + OUTPUT: an interval element containing ``wantval`` + + EXAMPLES:: + + sage: from sage.doctest.parsing import MarkedOutput, SageOutputChecker + sage: from sage.doctest.rif_tol import add_tolerance + sage: want_tol = MarkedOutput().update(tol=0.0001) + sage: want_abs = MarkedOutput().update(abs_tol=0.0001) + sage: want_rel = MarkedOutput().update(rel_tol=0.0001) + sage: add_tolerance(RIF(pi.n(64)), want_tol).endpoints() # needs sage.symbolic + (3.14127849432443, 3.14190681285516) + sage: add_tolerance(RIF(pi.n(64)), want_abs).endpoints() # needs sage.symbolic + (3.14149265358979, 3.14169265358980) + sage: add_tolerance(RIF(pi.n(64)), want_rel).endpoints() # needs sage.symbolic + (3.14127849432443, 3.14190681285516) + sage: add_tolerance(RIF(1e1000), want_tol) + 1.000?e1000 + sage: add_tolerance(RIF(1e1000), want_abs) + 1.000000000000000?e1000 + sage: add_tolerance(RIF(1e1000), want_rel) + 1.000?e1000 + sage: add_tolerance(0, want_tol) + 0.000? + sage: add_tolerance(0, want_abs) + 0.000? + sage: add_tolerance(0, want_rel) + 0 + """ + if want.tol: + if wantval == 0: + return RIFtol(want.tol) * RIFtol(-1, 1) + else: + return wantval * (1 + RIFtol(want.tol) * RIFtol(-1, 1)) + elif want.abs_tol: + return wantval + RIFtol(want.abs_tol) * RIFtol(-1, 1) + elif want.rel_tol: + return wantval * (1 + RIFtol(want.rel_tol) * RIFtol(-1, 1)) + else: + return wantval From 0aa6f448c12f0a97fd313b6995339c55915efb82 Mon Sep 17 00:00:00 2001 From: Aaron Dwyer Date: Sat, 3 Aug 2024 15:27:27 -0400 Subject: [PATCH 63/91] Changed the elifs in truncate columns --- src/sage/combinat/designs/covering_array.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sage/combinat/designs/covering_array.py b/src/sage/combinat/designs/covering_array.py index 43a7a846757..9582a627d22 100644 --- a/src/sage/combinat/designs/covering_array.py +++ b/src/sage/combinat/designs/covering_array.py @@ -88,11 +88,10 @@ def truncate_columns(array, k): if oldk == k: return array - elif oldk < k: + if oldk < k: raise ValueError("array only has {} columns".format(oldk)) - else: - return [row[:k] for row in array] + return [row[:k] for row in array] def Kleitman_Spencer_Katona(N): From 4d6e97b461c85eb6db7199726d584312636d814d Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 24 Jul 2024 08:09:14 +0900 Subject: [PATCH 64/91] Use correct class for dimension check --- src/sage/schemes/curves/affine_curve.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index c539968c294..ecc634d5a9f 100755 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -858,7 +858,7 @@ def __init__(self, A, X): if not A.base_ring() in Fields(): raise TypeError("curve not defined over a field") - d = self.dimension() + d = AlgebraicScheme_subscheme_affine_field.dimension(self) if d != 1: raise ValueError("defining equations (={}) define a scheme of dimension {} != 1".format(X, d)) @@ -920,7 +920,10 @@ def projection(self, indices, AS=None): To: Affine Space of dimension 3 over Rational Field Defn: Defined on coordinates by sending (x, y, z, w) to (x, y, z), - Affine Curve over Rational Field defined by c - 1, b - 3, a - 2) + Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: + c - 1, + b - 3, + a - 2) :: From 09035c0a5935240ea3bee1fdc5135c0a39cabf38 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 24 Jul 2024 14:20:10 +0900 Subject: [PATCH 65/91] Improve dimension computation for easy ideals --- .../polynomial/multi_polynomial_ideal.py | 96 ++++++++++--------- src/sage/schemes/curves/affine_curve.py | 11 +++ src/sage/schemes/curves/projective_curve.py | 13 +++ 3 files changed, 76 insertions(+), 44 deletions(-) diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index c3b85864863..526b437abbb 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -1225,6 +1225,17 @@ def dimension(self, singular=None): try: return self.__dimension except AttributeError: + if not self.base_ring().is_field(): + raise NotImplementedError("implemented only over fields") + if self.ngens() == 1: + g = self.gen(0) + if g.is_unit(): + self.__dimension = -1 + elif g: + self.__dimension = self.ring().ngens() - 1 + else: + self.__dimension = self.ring().ngens() + return self.__dimension try: from sage.libs.singular.function_factory import ff dim = ff.dim @@ -1235,50 +1246,47 @@ def dimension(self, singular=None): v = self._groebner_basis_singular_raw() self.__dimension = Integer(v.dim()) except TypeError: - if not self.base_ring().is_field(): - raise NotImplementedError("dimension() is implemented only over fields.") - if self.ring().term_order().is_global(): - verbose("Warning: falling back to very slow toy implementation.", level=0) - # See Chapter 9, Section 1 of Cox, Little, O'Shea's "Ideals, Varieties, - # and Algorithms". - from sage.sets.set import Set - gb = toy_buchberger.buchberger_improved(self) - if self.ring().one() in gb: - return Integer(-1) - ring_vars = self.ring().gens() - n = len(ring_vars) - lms = [each.lm() for each in gb] - # compute M_j, denoted by var_lms - var_lms = [Set([]) for _ in lms] - for j in range(len(ring_vars)): - for i in range(len(lms)): - if lms[i].degree(ring_vars[j]) > 0: - var_lms[i] += Set([j+1]) - # compute intersections of M_j and J - # we assume that the iterator starts with the empty set, - # then iterates through all subsets of order 1, - # then through all subsets of order 2, etc... - # the way Sage currently operates - all_J = Set([each + 1 for each in range(n)]).subsets() - min_dimension = -1 - all_J = iter(all_J) - while min_dimension == -1: - try: - J = next(all_J) - except StopIteration: - min_dimension = n - break - J_intersects_all = True - i = 0 - while J_intersects_all and i < len(var_lms): - J_intersects_all = J.intersection(var_lms[i]) != Set([]) - i += 1 - if J_intersects_all: - min_dimension = len(J) - return Integer(n - min_dimension) - else: - raise TypeError("Local/unknown orderings not supported by 'toy_buchberger' implementation.") - return self.__dimension + verbose("Warning: falling back to very slow toy implementation.", level=0) + if not self.ring().term_order().is_global(): + raise TypeError("local/unknown ordering is not supported by the toy implementation") + # See Chapter 9, Section 1 of Cox, Little, O'Shea's + # "Ideals, Varieties, and Algorithms" + from sage.sets.set import Set + gb = toy_buchberger.buchberger_improved(self) + if self.ring().one() in gb: + return Integer(-1) + ring_vars = self.ring().gens() + n = len(ring_vars) + lms = [each.lm() for each in gb] + # compute M_j, denoted by var_lms + var_lms = [Set([]) for _ in lms] + for j in range(len(ring_vars)): + for i in range(len(lms)): + if lms[i].degree(ring_vars[j]) > 0: + var_lms[i] += Set([j+1]) + # compute intersections of M_j and J + # we assume that the iterator starts with the empty set, + # then iterates through all subsets of order 1, + # then through all subsets of order 2, etc... + # the way Sage currently operates + all_J = Set([each + 1 for each in range(n)]).subsets() + min_dimension = -1 + all_J = iter(all_J) + while min_dimension == -1: + try: + J = next(all_J) + except StopIteration: + min_dimension = n + break + J_intersects_all = True + i = 0 + while J_intersects_all and i < len(var_lms): + J_intersects_all = J.intersection(var_lms[i]) != Set([]) + i += 1 + if J_intersects_all: + min_dimension = len(J) + self.__dimension = Integer(n - min_dimension) + return self.__dimension @require_field @handle_AA_and_QQbar diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index ecc634d5a9f..91006dc049d 100755 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -852,6 +852,17 @@ def __init__(self, A, X): sage: A. = AffineSpace(GF(7), 3) sage: C = Curve([x^2 - z, z - 8*x], A); C Affine Curve over Finite Field of size 7 defined by x^2 - z, -x + z + + TESTS:: + + sage: K. = QQ[] + sage: t1 = x^2*z^2 + y*t + sage: t2 = y*z^2 + x^2*t + sage: C = Curve([x^4-y^2-19,z^4-t^2-23,t1^2-t2^2-19*23]) + Traceback (most recent call last): + ... + ValueError: defining equations (=[x^4 - y^2 - 19, z^4 - t^2 - 23, + x^4*z^4 - y^2*z^4 - x^4*t^2 + y^2*t^2 - 437]) define a scheme of dimension 2 != 1 """ super().__init__(A, X) diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index a695f45411b..1badda100f5 100755 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -1593,12 +1593,25 @@ def __init__(self, A, X, category=None): sage: C = Curve(x*y^2*z^7 - x^10 - x^2*z^8) sage: loads(dumps(C)) == C True + + TESTS:: + + sage: P. = ProjectiveSpace(QQ, 4) + sage: C = Curve([x0^4 - x1^2*x4^2 - 19*x4^4, x2^4 - x3^2*x4^2 - 23*x4^4], P) + Traceback (most recent call last): + ... + ValueError: defining equations (=[x0^4 - x1^2*x4^2 - 19*x4^4, x2^4 - x3^2*x4^2 - 23*x4^4]) + define a scheme of dimension 2 != 1 """ super().__init__(A, X, category=category) if not A.base_ring() in Fields(): raise TypeError("curve not defined over a field") + d = AlgebraicScheme_subscheme_projective_field.dimension(self) + if d != 1: + raise ValueError(f"defining equations (={X}) define a scheme of dimension {d} != 1") + @lazy_attribute def _genus(self): """ From c355af5df126eecfc70620cd7a213ae67449db88 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 24 Jul 2024 15:07:50 +0900 Subject: [PATCH 66/91] Fix a doctest failure --- src/sage/rings/polynomial/multi_polynomial_ideal.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 526b437abbb..acd314d5b6b 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -1201,7 +1201,6 @@ def dimension(self, singular=None): sage: R. = PolynomialRing(GF(2147483659^2), order='lex') sage: I = R.ideal(0) sage: I.dimension() - verbose 0 (...: multi_polynomial_ideal.py, dimension) Warning: falling back to very slow toy implementation. 2 ALGORITHM: From 78f84f93d3fb7396b5b3171753c03da2dd87248c Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 24 Jul 2024 15:23:42 +0900 Subject: [PATCH 67/91] Return dimension as Integer --- src/sage/rings/polynomial/multi_polynomial_ideal.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index acd314d5b6b..376e1e48dba 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -1229,11 +1229,11 @@ def dimension(self, singular=None): if self.ngens() == 1: g = self.gen(0) if g.is_unit(): - self.__dimension = -1 + self.__dimension = Integer(-1) elif g: - self.__dimension = self.ring().ngens() - 1 + self.__dimension = Integer(self.ring().ngens() - 1) else: - self.__dimension = self.ring().ngens() + self.__dimension = Integer(self.ring().ngens()) return self.__dimension try: from sage.libs.singular.function_factory import ff @@ -1253,7 +1253,8 @@ def dimension(self, singular=None): from sage.sets.set import Set gb = toy_buchberger.buchberger_improved(self) if self.ring().one() in gb: - return Integer(-1) + self.__dimension = Integer(-1) + return self.__dimension ring_vars = self.ring().gens() n = len(ring_vars) lms = [each.lm() for each in gb] From 1befe347d97bb8363e2e5fc6d298452b5ba83efa Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 24 Jul 2024 15:38:45 +0900 Subject: [PATCH 68/91] Trimming doctest strings --- src/sage/schemes/curves/affine_curve.py | 2 +- src/sage/schemes/curves/projective_curve.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index 91006dc049d..1b6850744a4 100755 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -858,7 +858,7 @@ def __init__(self, A, X): sage: K. = QQ[] sage: t1 = x^2*z^2 + y*t sage: t2 = y*z^2 + x^2*t - sage: C = Curve([x^4-y^2-19,z^4-t^2-23,t1^2-t2^2-19*23]) + sage: C = Curve([x^4 - y^2 - 19, z^4 - t^2 - 23, t1^2 - t2^2 - 19*23]) Traceback (most recent call last): ... ValueError: defining equations (=[x^4 - y^2 - 19, z^4 - t^2 - 23, diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index 1badda100f5..f5d5fed49e0 100755 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -1597,7 +1597,7 @@ def __init__(self, A, X, category=None): TESTS:: sage: P. = ProjectiveSpace(QQ, 4) - sage: C = Curve([x0^4 - x1^2*x4^2 - 19*x4^4, x2^4 - x3^2*x4^2 - 23*x4^4], P) + sage: C = Curve([x0^4 - x1^2*x4^2 - 19*x4^4, x2^4 - x3^2*x4^2 - 23*x4^4]) Traceback (most recent call last): ... ValueError: defining equations (=[x0^4 - x1^2*x4^2 - 19*x4^4, x2^4 - x3^2*x4^2 - 23*x4^4]) From 7b69515ff8e1acbd2ea9d7f78868f37f3916c498 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 25 Jul 2024 07:27:32 +0900 Subject: [PATCH 69/91] Use super() --- src/sage/schemes/curves/affine_curve.py | 2 +- src/sage/schemes/curves/projective_curve.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index 1b6850744a4..d98209bdba1 100755 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -869,7 +869,7 @@ def __init__(self, A, X): if not A.base_ring() in Fields(): raise TypeError("curve not defined over a field") - d = AlgebraicScheme_subscheme_affine_field.dimension(self) + d = super(Curve_generic, self).dimension() if d != 1: raise ValueError("defining equations (={}) define a scheme of dimension {} != 1".format(X, d)) diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index f5d5fed49e0..8eff3715338 100755 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -1608,7 +1608,7 @@ def __init__(self, A, X, category=None): if not A.base_ring() in Fields(): raise TypeError("curve not defined over a field") - d = AlgebraicScheme_subscheme_projective_field.dimension(self) + d = super(Curve_generic, self).dimension() if d != 1: raise ValueError(f"defining equations (={X}) define a scheme of dimension {d} != 1") From 14b94d7ddd07e74802d90989ac45789480b970b6 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 25 Jul 2024 17:56:30 +0900 Subject: [PATCH 70/91] Update the docstring --- src/doc/en/reference/references/index.rst | 5 ++++- .../polynomial/multi_polynomial_ideal.py | 21 ++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst index db5afe04784..b819798f85d 100644 --- a/src/doc/en/reference/references/index.rst +++ b/src/doc/en/reference/references/index.rst @@ -3008,7 +3008,10 @@ REFERENCES: Texts in Mathematics, Springer, 2001. .. [Gre2006] \R. M. Green, *Star reducible Coxeter groups*, Glasgow - Mathematical Journal, Volume 48, Issue 3, pp. 583-609. + Mathematical Journal, Volume 48, Issue 3, pp. 583-609. + +.. [Ger2008] Gert-Martin Greuel and Gerhard Pfister. A Singular introduction + to commutative algebra. Vol. 348. Berlin: Springer, 2008. .. [Gri2021] \O. Gritsenko, *On strongly regular graph with parameters (65; 32; 15; 16)*, :arxiv:`2102.05432`. diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 376e1e48dba..bb9ee33b86f 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -1177,10 +1177,16 @@ def dimension(self, singular=None): If the ideal is the total ring, the dimension is `-1` by convention. + ALGORITHM: + + For principal ideals, Theorem 3.5.1 of [Ger2008]_ is used. Otherwise + Singular is used, unless the characteristic is too large. This requires + computation of a Groebner basis, which can be very expensive. + For polynomials over a finite field of order too large for Singular, - this falls back on a toy implementation of Buchberger to compute - the Groebner basis, then uses the algorithm described in Chapter 9, - Section 1 of Cox, Little, and O'Shea's "Ideals, Varieties, and Algorithms". + this falls back on a toy implementation of Buchberger to compute the + Groebner basis, then uses the algorithm described in Chapter 9, Section + 1 of Cox, Little, and O'Shea's "Ideals, Varieties, and Algorithms". EXAMPLES:: @@ -1203,10 +1209,6 @@ def dimension(self, singular=None): sage: I.dimension() 2 - ALGORITHM: - - Uses Singular, unless the characteristic is too large. - TESTS: Check that this method works over QQbar (:issue:`25351`):: @@ -1215,11 +1217,6 @@ def dimension(self, singular=None): sage: I = ideal(x^2-y, x^3-QQbar(-1)) # needs sage.rings.number_field sage: I.dimension() # needs sage.rings.number_field 1 - - .. NOTE:: - - Requires computation of a Groebner basis, which can be a - very expensive operation. """ try: return self.__dimension From 4cff2b03b2cea0f6a52747e18a2c7f7c1576e628 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Tue, 25 Jun 2024 12:38:40 +0900 Subject: [PATCH 71/91] Update deprecation policy --- src/doc/en/developer/coding_in_python.rst | 92 +++++++++++++++++------ 1 file changed, 68 insertions(+), 24 deletions(-) diff --git a/src/doc/en/developer/coding_in_python.rst b/src/doc/en/developer/coding_in_python.rst index 82dda02f209..bb08408777b 100644 --- a/src/doc/en/developer/coding_in_python.rst +++ b/src/doc/en/developer/coding_in_python.rst @@ -668,17 +668,28 @@ Deprecation =========== When making a **backward-incompatible** modification in Sage, the old code should -keep working and display a message indicating how it should be updated/written -in the future. We call this a *deprecation*. +keep working and a message indicating how the code should be updated/written +in the future should be displayed somewhere. We call this *deprecation*. We explain +how to do the deprecation, the deprecation policy, below. + +Any class, function, method, or attribute defined in a file under +:sage_root:`src/sage` is subject to the deprecation policy. If its name starts +with an underscore, then it is considered internal, and exempt from the +deprecation policy. .. NOTE:: - Deprecated code can only be removed one year after the first - stable release in which it appeared. + A deprecated class, function, method, or attribute can only be removed one + year after the first stable release in which it appeared. + +When a deprecated function, method, or attribute is used, a deprecation warning +is issued. The warning message contains the number of the GitHub PR that +implemented the deprecation. We use 12345 in the examples below. -Each deprecation warning contains the number of the GitHub PR that defines -it. We use 666 in the examples below. For each entry, consult the function's -documentation for more information on its behaviour and optional arguments. +.. NOTE:: + + For deprecation tools used in the examples, consult the tool's documentation for more + information on its behaviour and optional arguments. * **Rename a keyword:** by decorating a function/method with :class:`~sage.misc.decorators.rename_keyword`, any user calling @@ -687,7 +698,7 @@ documentation for more information on its behaviour and optional arguments. .. CODE-BLOCK:: python from sage.misc.decorators import rename_keyword - @rename_keyword(deprecation=666, my_old_keyword='my_new_keyword') + @rename_keyword(deprecation=12345, my_old_keyword='my_new_keyword') def my_function(my_new_keyword=True): return my_new_keyword @@ -701,7 +712,7 @@ documentation for more information on its behaviour and optional arguments. def my_new_function(): ... - my_old_function = deprecated_function_alias(666, my_new_function) + my_old_function = deprecated_function_alias(12345, my_new_function) * **Moving an object to a different module:** if you rename a source file or move some function (or class) to a @@ -713,7 +724,7 @@ documentation for more information on its behaviour and optional arguments. .. CODE-BLOCK:: python from sage.misc.lazy_import import lazy_import - lazy_import('sage.new.module.name', 'name_of_the_function', deprecation=666) + lazy_import('sage.new.module.name', 'name_of_the_function', deprecation=12345) You can also lazily import everything using ``*`` or a few functions using a tuple: @@ -721,8 +732,8 @@ documentation for more information on its behaviour and optional arguments. .. CODE-BLOCK:: python from sage.misc.lazy_import import lazy_import - lazy_import('sage.new.module.name', '*', deprecation=666) - lazy_import('sage.other.module', ('func1', 'func2'), deprecation=666) + lazy_import('sage.new.module.name', '*', deprecation=12345) + lazy_import('sage.other.module', ('func1', 'func2'), deprecation=12345) * **Remove a name from a global namespace:** this is when you want to remove a name from a global namespace (say, ``sage.all`` or some @@ -736,7 +747,7 @@ documentation for more information on its behaviour and optional arguments. .. CODE-BLOCK:: python from sage.misc.lazy_import import lazy_import as _lazy_import - _lazy_import('sage.some.package', 'some_function', deprecation=666) + _lazy_import('sage.some.package', 'some_function', deprecation=12345) * **Any other case:** if none of the cases above apply, call :func:`~sage.misc.superseded.deprecation` in the function that you want to @@ -746,18 +757,51 @@ documentation for more information on its behaviour and optional arguments. .. CODE-BLOCK:: python from sage.misc.superseded import deprecation - deprecation(666, "Do not use your computer to compute 1+1. Use your brain.") + deprecation(12345, "Do not use your computer to compute 1 + 1. Use your brain.") + +.. NOTE:: + + These decorators only work for Python. There is no implementation + of decorators in Cython. Hence, when in need to rename a keyword/function/method/... + in a Cython (.pyx) file and/or to deprecate something, forget about decorators and + just use :func:`~sage.misc.superseded.deprecation_cython` instead. The usage of + :func:`~sage.misc.superseded.deprecation_cython` is exactly the same as + :func:`~sage.misc.superseded.deprecation`. + +When a class is renamed or removed, it should be deprecated unless it is +internal. A class is internal if its name starts with an underscore, or experts +(authors and reviewers of a PR making changes to the class) agree that the +class is unlikely to be directly imported by user code. Otherwise, or if experts +disagree, it is public. + +As a class is imported rather than run by user code, there are some technical +difficulties in using the above deprecation tools. Instead we follow +the procedure below: + +* **Renaming a class:** rename ``OldClass`` to ``NewClass`` and add an + alias ``OldClass = NewClass``: + + .. CODE-BLOCK:: python + + class NewClass: + ... + + OldClass = NewClass # OldClass is deprecated. See Issue 12345. + +* **Removing a class:** add a comment: + + .. CODE-BLOCK:: python + + # OldClass is deprecated. See Issue 12345. + + class OldClass: -Note that these decorators only work for (pure) Python. There is no implementation -of decorators in Cython. Hence, when in need to rename a keyword/function/method/... -in a Cython (.pyx) file and/or to deprecate something, forget about decorators and -just use :func:`~sage.misc.superseded.deprecation_cython` instead. The usage of -:func:`~sage.misc.superseded.deprecation_cython` is exactly the same as -:func:`~sage.misc.superseded.deprecation`. +In both cases, make it sure to display the change in the "Deprecations" +section of the release notes of the next stable release. Experimental/unstable code --------------------------- +========================== You can mark your newly created code (classes/functions/methods) as experimental/unstable. In this case, no deprecation warning is needed @@ -778,7 +822,7 @@ reviewing process. .. CODE-BLOCK:: python from sage.misc.superseded import experimental - @experimental(66666) + @experimental(12345) def experimental_function(): # do something @@ -790,7 +834,7 @@ reviewing process. from sage.misc.superseded import experimental class experimental_class(SageObject): - @experimental(66666) + @experimental(12345) def __init__(self, some, arguments): # do something @@ -801,7 +845,7 @@ reviewing process. .. CODE-BLOCK:: python from sage.misc.superseded import experimental_warning - experimental_warning(66666, 'This code is not foolproof.') + experimental_warning(12345, 'This code is not foolproof.') Using optional packages From cb0da58eb99dce66c7ae067ec44695c559e77fc3 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Wed, 19 Jun 2024 17:31:10 +0900 Subject: [PATCH 72/91] Simplify docbuild --- src/doc/Makefile | 4 ++-- src/sage_docbuild/__main__.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/doc/Makefile b/src/doc/Makefile index 2d433b3727c..98a3d138baf 100644 --- a/src/doc/Makefile +++ b/src/doc/Makefile @@ -42,7 +42,7 @@ doc-inventory-reference: doc-src $(eval BIBLIO = $(firstword $(DOCS))) $(eval OTHER_DOCS = $(wordlist 2, 100, $(DOCS))) $(MAKE) doc-inventory--$(subst /,-,$(BIBLIO)) - $(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" $(foreach doc, $(OTHER_DOCS), doc-inventory--$(subst /,-,$(doc))) + $(MAKE) $(foreach doc, $(OTHER_DOCS), doc-inventory--$(subst /,-,$(doc))) $(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" doc-inventory--reference_top endif @@ -63,7 +63,7 @@ doc-html-reference: doc-html-reference-sub doc-html-other: doc-html-reference $(eval DOCS = $(shell sage --docbuild --all-documents all)) @if [ -z "$(DOCS)" ]; then echo "Error: 'sage --docbuild --all-documents' failed"; exit 1; fi - $(MAKE) SAGE_DOCBUILD_OPTS="$(SAGE_DOCBUILD_OPTS) --no-prune-empty-dirs" $(foreach doc, $(wordlist 2, 100, $(DOCS)), doc-html--$(subst /,-,$(doc))) + $(MAKE) $(foreach doc, $(wordlist 2, 100, $(DOCS)), doc-html--$(subst /,-,$(doc))) doc-html: doc-html-reference doc-html-other diff --git a/src/sage_docbuild/__main__.py b/src/sage_docbuild/__main__.py index 844e1ebee17..a7b7b39880b 100644 --- a/src/sage_docbuild/__main__.py +++ b/src/sage_docbuild/__main__.py @@ -46,7 +46,7 @@ option: nitpicky) --check-nested check picklability of nested classes in DOCUMENT 'reference' --no-prune-empty-dirs - do not prune empty directories in the documentation sources + do not prune empty directories in the documentation source --use-cdns assume internet connection and use CDNs; in particular, use MathJax CDN -N, --no-colors do not color output; does not affect children @@ -325,7 +325,7 @@ def setup_parser(): help="check picklability of nested classes in DOCUMENT 'reference'") standard.add_argument("--no-prune-empty-dirs", dest="no_prune_empty_dirs", action="store_true", - help="do not prune empty directories in the documentation sources") + help="do not prune empty directories in the documentation source") standard.add_argument("--use-cdns", dest="use_cdns", default=False, action="store_true", help="assume internet connection and use CDNs; in particular, use MathJax CDN") @@ -508,22 +508,24 @@ def excepthook(*exc_info): build_options.ABORT_ON_ERROR = not args.keep_going + # Set up Intersphinx cache + _ = IntersphinxCache() + + builder = get_builder(name) + if not args.no_prune_empty_dirs: # Delete empty directories. This is needed in particular for empty # directories due to "git checkout" which never deletes empty # directories it leaves behind. See Issue #20010. # Issue #31948: This is not parallelization-safe; use the option # --no-prune-empty-dirs to turn it off - for dirpath, dirnames, filenames in os.walk(SAGE_DOC_SRC, topdown=False): + for dirpath, dirnames, filenames in os.walk(builder.dir, topdown=False): if not dirnames + filenames: logger.warning('Deleting empty directory {0}'.format(dirpath)) os.rmdir(dirpath) - # Set up Intersphinx cache - _ = IntersphinxCache() - - builder = getattr(get_builder(name), typ) - builder() + build = getattr(builder, typ) + build() if __name__ == '__main__': From 358058604ba688e248fe5172343030902f1b53a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 28 Jul 2024 17:18:17 +0200 Subject: [PATCH 73/91] move unit and zero ideal to category framework --- .../coercion_and_categories.rst | 4 -- src/sage/categories/rings.py | 44 +++++++++++++ src/sage/rings/quotient_ring.py | 9 ++- src/sage/rings/ring.pxd | 2 - src/sage/rings/ring.pyx | 65 ------------------- src/sage/rings/tate_algebra.py | 4 +- 6 files changed, 53 insertions(+), 75 deletions(-) diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst index b55fe562555..4698fd3321b 100644 --- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst +++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst @@ -119,9 +119,7 @@ This base class provides a lot more methods than a general parent:: '_list', '_one_element', '_pseudo_fraction_field', - '_unit_ideal', '_zero_element', - '_zero_ideal', 'algebraic_closure', 'base_extend', 'divides', @@ -146,9 +144,7 @@ This base class provides a lot more methods than a general parent:: 'prime_subfield', 'principal_ideal', 'random_element', - 'unit_ideal', 'zero', - 'zero_ideal', 'zeta', 'zeta_order'] diff --git a/src/sage/categories/rings.py b/src/sage/categories/rings.py index 5ae70e2ea7f..a105d2ed67d 100644 --- a/src/sage/categories/rings.py +++ b/src/sage/categories/rings.py @@ -709,6 +709,50 @@ def _ideal_class_(self, n=0): from sage.rings.noncommutative_ideals import Ideal_nc return Ideal_nc + @cached_method + def zero_ideal(self): + """ + Return the zero ideal of this ring (cached). + + EXAMPLES:: + + sage: ZZ.zero_ideal() + Principal ideal (0) of Integer Ring + sage: QQ.zero_ideal() + Principal ideal (0) of Rational Field + sage: QQ['x'].zero_ideal() + Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field + + The result is cached:: + + sage: ZZ.zero_ideal() is ZZ.zero_ideal() + True + + TESTS: + + Make sure that :issue:`13644` is fixed:: + + sage: # needs sage.rings.padics + sage: K = Qp(3) + sage: R. = K[] + sage: L. = K.extension(a^2-3) + sage: L.ideal(a) + Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3 + """ + return self._ideal_class_()(self, [self.zero()], coerce=False) + + @cached_method + def unit_ideal(self): + """ + Return the unit ideal of this ring. + + EXAMPLES:: + + sage: Zp(7).unit_ideal() # needs sage.rings.padics + Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20 + """ + return self._ideal_class_()(self, [self.one()], coerce=False) + def characteristic(self): """ Return the characteristic of this ring. diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py index b2d3c52bca3..3d429aeff15 100644 --- a/src/sage/rings/quotient_ring.py +++ b/src/sage/rings/quotient_ring.py @@ -1474,10 +1474,14 @@ def _macaulay2_init_(self, macaulay2=None): I = self.defining_ideal()._macaulay2_(macaulay2) return I.ring()._operator('/', I) - def _ideal_class_(self, num_gens): + def _ideal_class_(self, n=0): r""" Use a specialized class for quotient ring ideals. + INPUT: + + - ``n`` -- optional integer, the number of generators + EXAMPLES:: sage: type(Zmod(14).ideal(2)) @@ -1487,10 +1491,11 @@ def _ideal_class_(self, num_gens): sage: type(Zmod(14).ideal([2,7])) """ - if num_gens == 1: + if n == 1: return QuotientRingIdeal_principal return QuotientRingIdeal_generic + class QuotientRingIdeal_generic(ideal.Ideal_generic): r""" Specialized class for quotient-ring ideals. diff --git a/src/sage/rings/ring.pxd b/src/sage/rings/ring.pxd index 1b0c21e1dd3..7f09fd80e87 100644 --- a/src/sage/rings/ring.pxd +++ b/src/sage/rings/ring.pxd @@ -6,8 +6,6 @@ cpdef bint _is_Field(x) except -2 cdef class Ring(ParentWithGens): cdef public object _zero_element cdef public object _one_element - cdef public object _zero_ideal - cdef public object _unit_ideal cdef class CommutativeRing(Ring): diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx index b2e11b93678..5ad885351cc 100644 --- a/src/sage/rings/ring.pyx +++ b/src/sage/rings/ring.pyx @@ -510,71 +510,6 @@ cdef class Ring(ParentWithGens): else: raise TypeError("Don't know how to transform %s into an ideal of %s" % (self, x)) - def principal_ideal(self, gen, coerce=True): - """ - Return the principal ideal generated by gen. - - EXAMPLES:: - - sage: R. = ZZ[] - sage: R.principal_ideal(x+2*y) - Ideal (x + 2*y) of Multivariate Polynomial Ring in x, y over Integer Ring - """ - C = self._ideal_class_(1) - if coerce: - gen = self(gen) - return C(self, [gen]) - - def unit_ideal(self): - """ - Return the unit ideal of this ring. - - EXAMPLES:: - - sage: Zp(7).unit_ideal() # needs sage.rings.padics - Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20 - """ - if self._unit_ideal is None: - I = Ring.ideal(self, [self(1)], coerce=False) - self._unit_ideal = I - return I - return self._unit_ideal - - def zero_ideal(self): - """ - Return the zero ideal of this ring (cached). - - EXAMPLES:: - - sage: ZZ.zero_ideal() - Principal ideal (0) of Integer Ring - sage: QQ.zero_ideal() - Principal ideal (0) of Rational Field - sage: QQ['x'].zero_ideal() - Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field - - The result is cached:: - - sage: ZZ.zero_ideal() is ZZ.zero_ideal() - True - - TESTS: - - Make sure that :issue:`13644` is fixed:: - - sage: # needs sage.rings.padics - sage: K = Qp(3) - sage: R. = K[] - sage: L. = K.extension(a^2-3) - sage: L.ideal(a) - Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3 - """ - if self._zero_ideal is None: - I = Ring.ideal(self, [self.zero()], coerce=False) - self._zero_ideal = I - return I - return self._zero_ideal - def zero(self): """ Return the zero element of this ring (cached). diff --git a/src/sage/rings/tate_algebra.py b/src/sage/rings/tate_algebra.py index 7118e1d386b..038aba16d83 100644 --- a/src/sage/rings/tate_algebra.py +++ b/src/sage/rings/tate_algebra.py @@ -870,13 +870,13 @@ def _pushout_(self, R): else: return A.integer_ring() - def _ideal_class_(self, n): + def _ideal_class_(self, n=0): r""" Return the class that handles ideals in this Tate algebra. INPUT: - - ``n`` -- number of generators + - ``n`` -- optional integer, number of generators EXAMPLES:: From 6a69e9a14992e5b32cf37e2f214bb03eea0cbc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 28 Jul 2024 17:35:32 +0200 Subject: [PATCH 74/91] move principal ideal to category framework --- src/sage/categories/rings.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sage/categories/rings.py b/src/sage/categories/rings.py index a105d2ed67d..3ea37b7b117 100644 --- a/src/sage/categories/rings.py +++ b/src/sage/categories/rings.py @@ -739,7 +739,7 @@ def zero_ideal(self): sage: L.ideal(a) Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3 """ - return self._ideal_class_()(self, [self.zero()], coerce=False) + return self._ideal_class_()(self, [self.zero()]) @cached_method def unit_ideal(self): @@ -751,7 +751,22 @@ def unit_ideal(self): sage: Zp(7).unit_ideal() # needs sage.rings.padics Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20 """ - return self._ideal_class_()(self, [self.one()], coerce=False) + return self._ideal_class_()(self, [self.one()]) + + def principal_ideal(self, gen, coerce=True): + """ + Return the principal ideal generated by gen. + + EXAMPLES:: + + sage: R. = ZZ[] + sage: R.principal_ideal(x+2*y) + Ideal (x + 2*y) of Multivariate Polynomial Ring in x, y over Integer Ring + """ + C = self._ideal_class_(1) + if coerce: + gen = self(gen) + return C(self, [gen]) def characteristic(self): """ From 63fbb99d1cf7705862a6617209a45c0e4fe42d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 28 Jul 2024 18:15:09 +0200 Subject: [PATCH 75/91] fix doctest --- src/doc/en/thematic_tutorials/coercion_and_categories.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst index 4698fd3321b..8da15b32efa 100644 --- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst +++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst @@ -142,7 +142,6 @@ This base class provides a lot more methods than a general parent:: 'one', 'order', 'prime_subfield', - 'principal_ideal', 'random_element', 'zero', 'zeta', From aebba30074088f3db9a090f5d7d64d0db3638785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 28 Jul 2024 19:57:34 +0200 Subject: [PATCH 76/91] fix one doctest --- src/sage/categories/rings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/categories/rings.py b/src/sage/categories/rings.py index 3ea37b7b117..781f1a1462b 100644 --- a/src/sage/categories/rings.py +++ b/src/sage/categories/rings.py @@ -739,7 +739,7 @@ def zero_ideal(self): sage: L.ideal(a) Principal ideal (1 + O(a^40)) of 3-adic Eisenstein Extension Field in a defined by a^2 - 3 """ - return self._ideal_class_()(self, [self.zero()]) + return self._ideal_class_(1)(self, [self.zero()]) @cached_method def unit_ideal(self): @@ -751,7 +751,7 @@ def unit_ideal(self): sage: Zp(7).unit_ideal() # needs sage.rings.padics Principal ideal (1 + O(7^20)) of 7-adic Ring with capped relative precision 20 """ - return self._ideal_class_()(self, [self.one()]) + return self._ideal_class_(1)(self, [self.one()]) def principal_ideal(self, gen, coerce=True): """ From b66bbb83459ede4c403da52fcef18524c81317d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 30 Jul 2024 10:55:40 +0200 Subject: [PATCH 77/91] doc as suggested --- src/sage/rings/quotient_ring.py | 2 +- src/sage/rings/tate_algebra.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py index 3d429aeff15..4cf3979265f 100644 --- a/src/sage/rings/quotient_ring.py +++ b/src/sage/rings/quotient_ring.py @@ -1480,7 +1480,7 @@ def _ideal_class_(self, n=0): INPUT: - - ``n`` -- optional integer, the number of generators + - ``n`` -- integer (default: ``0``); the number of generators EXAMPLES:: diff --git a/src/sage/rings/tate_algebra.py b/src/sage/rings/tate_algebra.py index 038aba16d83..d80060696be 100644 --- a/src/sage/rings/tate_algebra.py +++ b/src/sage/rings/tate_algebra.py @@ -876,7 +876,7 @@ def _ideal_class_(self, n=0): INPUT: - - ``n`` -- optional integer, number of generators + - ``n`` -- integer (default: ``0``); the number of generators EXAMPLES:: From 2f3affc87c6b201e5f4bd4a34723356de1e02e09 Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Sun, 4 Aug 2024 19:10:55 +0200 Subject: [PATCH 78/91] correct & tweak documentation --- src/sage/schemes/elliptic_curves/ell_point.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 676b71b5813..a85f6473772 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -3955,12 +3955,13 @@ def log(self, base): For anomalous curves with `\#E = p`, the :meth:`padic_elliptic_logarithm` function is called. - For two-dimensional logarithms, we first compute the Weil pairing of - `Q` with `P_1` and `P_2` and their logarithms to base the pairing of - `P_1` and `P_2`; this allows to read off `x` and `y` modulo the part - of the order where `P_1` and `P_2`. Modulo the rest of the order the - logarithm is effectively one-dimensional, so we can reduce the problem - to the basic one-dimensional case and finally recombine the results. + For two-dimensional logarithms, we first compute the Weil pairings + of `Q` with `P_1` and `P_2` and their logarithms relative to the + pairing of `P_1` and `P_2`; this allows reading off `x` and `y` + modulo the part of the order where `P_1` and `P_2` are independent. + Modulo the remaining part of the order the logarithm ends up being + effectively one-dimensional, so we can reduce the problem to the + basic one-dimensional case and finally recombine the results. INPUT: From 9cb9f0777d842202c637f7205f83f0d9c35771ee Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 4 Aug 2024 11:12:03 -0700 Subject: [PATCH 79/91] build/pkgs/furo/version_requirements.txt: Set lower bound --- build/pkgs/furo/version_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/furo/version_requirements.txt b/build/pkgs/furo/version_requirements.txt index a95ae18b4f9..acdc1d6ef56 100644 --- a/build/pkgs/furo/version_requirements.txt +++ b/build/pkgs/furo/version_requirements.txt @@ -1 +1 @@ -furo +furo >= 2024.7.18 From e9030ad9acd516c787a23573162847aa50a4f7e9 Mon Sep 17 00:00:00 2001 From: Giacomo Pope Date: Mon, 5 Aug 2024 13:36:03 +0100 Subject: [PATCH 80/91] add compose mod method to polynomial rings over extension fields --- src/sage/libs/ntl/ZZ_pEX.pxd | 2 + .../rings/polynomial/polynomial_zz_pex.pyx | 60 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/sage/libs/ntl/ZZ_pEX.pxd b/src/sage/libs/ntl/ZZ_pEX.pxd index 78be3ee13ea..df3a38602ff 100644 --- a/src/sage/libs/ntl/ZZ_pEX.pxd +++ b/src/sage/libs/ntl/ZZ_pEX.pxd @@ -82,6 +82,8 @@ cdef extern from "ntlwrap.h": void ZZ_pEX_DivRem_pre "DivRem"(ZZ_pEX_c q, ZZ_pEX_c r, ZZ_pEX_c a, ZZ_pEX_Modulus_c F) void ZZ_pEX_div_pre "div"(ZZ_pEX_c q, ZZ_pEX_c a, ZZ_pEX_Modulus_c F) + void ZZ_pEX_CompMod "CompMod"(ZZ_pEX_c x, ZZ_pEX_c f, ZZ_pEX_c g, ZZ_pEX_Modulus_c F) + void ZZ_pEX_MinPolyMod "MinPolyMod"(ZZ_pEX_c h, ZZ_pEX_c g, ZZ_pEX_c f) void ZZ_pEX_MinPolyMod_pre "MinPolyMod"(ZZ_pEX_c h, ZZ_pEX_c g, ZZ_pEX_Modulus_c F) diff --git a/src/sage/rings/polynomial/polynomial_zz_pex.pyx b/src/sage/rings/polynomial/polynomial_zz_pex.pyx index 48544dbbe20..20b59c2d3a2 100644 --- a/src/sage/rings/polynomial/polynomial_zz_pex.pyx +++ b/src/sage/rings/polynomial/polynomial_zz_pex.pyx @@ -711,3 +711,63 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): ZZ_pEX_PowerMod_ZZ_pre(r.x, y, e_ZZ, mod) sig_off() return r + + def modular_composition(self, other, modulus): + r""" + Compute `f(g) \pmod h`. + + To be precise about the order fo compostion, given ``self``, ``other`` + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + + INPUT: + + - ``other`` -- a polynomial `g(x)` + - ``modulus`` -- a polynomial `h(x)` + + EXAMPLES:: + + sage: R. = GF(3**6)[] + sage: f = R.random_element() + sage: g = R.random_element() + sage: g.modular_composition(g, f) == g(g) % f + True + + sage: F. = GF(3**6) + sage: R. = F[] + sage: f = 2*z3^2*x^2 + (z3 + 1)*x + z3^2 + 2 + sage: g = (z3^2 + 2*z3)*x^2 + (2*z3 + 2)*x + 2*z3^2 + z3 + 2 + sage: h = (2*z3 + 2)*x^2 + (2*z3^2 + 1)*x + 2*z3^2 + z3 + 2 + sage: f.modular_composition(g, h) + (z3^5 + z3^4 + z3^3 + z3^2 + z3)*x + z3^5 + z3^3 + 2*z3 + 2 + sage: f.modular_composition(g, h) == f(g) % h + True + + AUTHORS: + + - Giacomo Pope (2024-08) initial implementation + """ + self._parent._modulus.restore() + + # Ensure all the parents match + if other.parent() is not self._parent: + other = self._parent.coerce(other) + if modulus.parent() is not self._parent: + modulus = self._parent.coerce(modulus) + + # Create the output polynomial + cdef Polynomial_ZZ_pEX r + r = Polynomial_ZZ_pEX.__new__(Polynomial_ZZ_pEX) + celement_construct(&r.x, (self)._cparent) + r._parent = (self)._parent + r._cparent = (self)._cparent + + # Create ZZ_pEX_Modulus type from modulus input + cdef ZZ_pEX_Modulus_c mod + ZZ_pEX_Modulus_build(mod, (modulus).x) + + # Compute f(g) mod h + sig_on() + ZZ_pEX_CompMod(r.x, (self).x, ((other % modulus)).x, mod) + sig_off() + + return r From a0be37d771a029a9670fe40dd61129baba5c1bd5 Mon Sep 17 00:00:00 2001 From: Giacomo Pope Date: Mon, 5 Aug 2024 15:06:37 +0100 Subject: [PATCH 81/91] add compose mod method to polynomial rings over GF(p) for flint and NTL --- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 40 +++++++++++++++++++ .../polynomial/polynomial_modn_dense_ntl.pyx | 38 ++++++++++++++++++ .../polynomial/polynomial_zmod_flint.pyx | 40 +++++++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 23a0b0d7373..16b708fb0d4 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -1472,6 +1472,46 @@ cdef class ntl_ZZ_pX(): #ZZ_pX_preallocate_space(&self.x, n) sig_off() + def modular_composition(self, ntl_ZZ_pX other, ntl_ZZ_pX modulus): + r""" + Compute `f(g) \pmod h`. + + To be precise about the order fo compostion, given ``self``, ``other`` + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + + INPUT: + + - ``other`` -- a polynomial `g(x)` + - ``modulus`` -- a polynomial `h(x)` + + EXAMPLES:: + + sage: c = ntl.ZZ_pContext(17) + sage: f = ntl.ZZ_pX([1,2,3],c) + sage: g = ntl.ZZ_pX([3,2,1],c) + sage: h = ntl.ZZ_pX([1,0,1],c) + sage: f.modular_composition(g, h) + [5 11] + + AUTHORS: + + - Giacomo Pope (2024-08) initial implementation + """ + cdef ntl_ZZ_pX r = self._new() + cdef ZZ_pX_Modulus_c mod + + sig_on() + # NTL requires that g is reduced + other = other % modulus + + # Build the modulus type + ZZ_pX_Modulus_build(mod, modulus.x) + + # Compute f(g) % h + ZZ_pX_CompMod(r.x, self.x, other.x, mod) + sig_off() + return r + cdef class ntl_ZZ_pX_Modulus(): """ Thin holder for ZZ_pX_Moduli. diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index d315cc1059e..973395cd4db 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -424,6 +424,44 @@ cdef class Polynomial_dense_mod_n(Polynomial): """ return small_roots(self, *args, **kwds) + def modular_composition(self, other, modulus): + r""" + Compute `f(g) \pmod h`. + + To be precise about the order fo compostion, given ``self``, ``other`` + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + + INPUT: + + - ``other`` -- a polynomial `g(x)` + - ``modulus`` -- a polynomial `h(x)` + + EXAMPLES:: + + sage: R. = GF(2**127 - 1)[] + sage: f = R.random_element() + sage: g = R.random_element() + sage: g.modular_composition(g, f) == g(g) % f + True + + sage: R. = GF(163)[] + sage: f = R([i for i in range(100)]) + sage: g = R([i**2 for i in range(100)]) + sage: h = 1 + x + x**5 + sage: f.modular_composition(g, h) + 82*x^4 + 56*x^3 + 45*x^2 + 60*x + 127 + sage: f.modular_composition(g, h) == f(g) % h + True + + AUTHORS: + + - Giacomo Pope (2024-08) initial implementation + """ + elt = self.ntl_ZZ_pX() + mod = modulus.ntl_ZZ_pX() + other = other.ntl_ZZ_pX() + res = elt.modular_composition(other, mod) + return self.parent()(res, construct=True) def small_roots(self, X=None, beta=1.0, epsilon=None, **kwds): r""" diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx index 80063d7462c..2d8538a0ba7 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx @@ -989,3 +989,43 @@ cdef class Polynomial_zmod_flint(Polynomial_template): from sage.rings.polynomial.polynomial_ring_constructor import _single_variate R = _single_variate(parent.base_ring(), name=name, implementation='NTL') return parent(R(self % other).minpoly_mod(R(other))) + + def modular_composition(self, other, modulus): + r""" + Compute `f(g) \pmod h`. + + To be precise about the order fo compostion, given ``self``, ``other`` + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + + INPUT: + + - ``other`` -- a polynomial `g(x)` + - ``modulus`` -- a polynomial `h(x)` + + EXAMPLES:: + + sage: R. = GF(163)[] + sage: f = R.random_element() + sage: g = R.random_element() + sage: g.modular_composition(g, f) == g(g) % f + True + + sage: f = R([i for i in range(100)]) + sage: g = R([i**2 for i in range(100)]) + sage: h = 1 + x + x**5 + sage: f.modular_composition(g, h) + 82*x^4 + 56*x^3 + 45*x^2 + 60*x + 127 + sage: f.modular_composition(g, h) == f(g) % h + True + + AUTHORS: + + - Giacomo Pope (2024-08) initial implementation + """ + cdef Polynomial_zmod_flint res = self._new() + + sig_on() + nmod_poly_compose_mod(&res.x, &(self).x, &(other).x, &(modulus).x) + sig_off() + + return res From d424bdacde1e5cf047fa5885e6b5a8d78e6d3b5b Mon Sep 17 00:00:00 2001 From: Giacomo Pope Date: Mon, 5 Aug 2024 15:18:52 +0100 Subject: [PATCH 82/91] linter fix --- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 4 ++-- src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx | 3 ++- src/sage/rings/polynomial/polynomial_zmod_flint.pyx | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 16b708fb0d4..00db3039b3a 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -1478,7 +1478,7 @@ cdef class ntl_ZZ_pX(): To be precise about the order fo compostion, given ``self``, ``other`` and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. - + INPUT: - ``other`` -- a polynomial `g(x)` @@ -1503,7 +1503,7 @@ cdef class ntl_ZZ_pX(): sig_on() # NTL requires that g is reduced other = other % modulus - + # Build the modulus type ZZ_pX_Modulus_build(mod, modulus.x) diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index 973395cd4db..615379dc157 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -430,7 +430,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): To be precise about the order fo compostion, given ``self``, ``other`` and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. - + INPUT: - ``other`` -- a polynomial `g(x)` @@ -463,6 +463,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): res = elt.modular_composition(other, mod) return self.parent()(res, construct=True) + def small_roots(self, X=None, beta=1.0, epsilon=None, **kwds): r""" Let `N` be the characteristic of the base ring this polynomial diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx index 2d8538a0ba7..e591aafc1df 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx @@ -996,7 +996,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): To be precise about the order fo compostion, given ``self``, ``other`` and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. - + INPUT: - ``other`` -- a polynomial `g(x)` From 5c875f454016583297dbba623f470d6c0341d57b Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Tue, 2 Jul 2024 23:29:55 +0100 Subject: [PATCH 83/91] use pkg-config to find msolve, otherwise try to run it --- build/pkgs/msolve/spkg-configure.m4 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 build/pkgs/msolve/spkg-configure.m4 diff --git a/build/pkgs/msolve/spkg-configure.m4 b/build/pkgs/msolve/spkg-configure.m4 new file mode 100644 index 00000000000..b0440b9b071 --- /dev/null +++ b/build/pkgs/msolve/spkg-configure.m4 @@ -0,0 +1,23 @@ +SAGE_SPKG_CONFIGURE([msolve], [ + PKG_CHECK_MODULES([msolve], [msolve >= 0.6.5], [], [ + AC_CACHE_CHECK([for msolve], [ac_cv_path_MSOLVE], + [AC_PATH_PROGS_FEATURE_CHECK([MSOLVE], [msolve], + [msolvin=$(mktemp) + msolvout=$(mktemp) + msolvchk=$(mktemp) + echo -e 'x,y\n0\nx-y,\nx*y-1' >$msolvin + changequote(<<, >>)dnl + echo -e '[0, [1,\n[[[-1, -1], [-1, -1]], [[1, 1], [1, 1]]]\n]]:' >$msolvchk + changequote([, ])dnl + $ac_path_MSOLVE -f $msolvin -o $msolvout + AS_IF([test x$(diff $msolvout $msolvchk) = x], + [ac_cv_path_MSOLVE=$ac_path_MSOLVE + ac_path_MSOLVE_found=:], + [sage_spkg_install_msolve=yes + AC_MSG_RESULT([could not find working msolve]) + ]) + ], [sage_spkg_install_msolve=yes + AC_MSG_RESULT([could not find working msolve]) + ])]) + ]) +]) From b167f75d39e5858630c52c65ffca525994d0b171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 6 Aug 2024 10:06:50 +0200 Subject: [PATCH 84/91] adding doctest --- src/sage/symbolic/expression_conversions.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sage/symbolic/expression_conversions.py b/src/sage/symbolic/expression_conversions.py index 62582e5202b..2d59c66293c 100644 --- a/src/sage/symbolic/expression_conversions.py +++ b/src/sage/symbolic/expression_conversions.py @@ -1811,7 +1811,17 @@ class HalfAngle(ExpressionTreeWalker): def __init__(self, ex): """ - Initialize. + A class that walks a symbolic expression tree, replacing each + occurrence of a trigonometric or hyperbolic function by its + expression as a rational fraction in the (hyperbolic) tangent + of half the original argument. + + EXAMPLES:: + + sage: a, b = SR.var("a, b") + sage: from sage.symbolic.expression_conversions import HalfAngle + sage: HalfAngle(tan(a))(tan(a)+4) + -2*tan(1/2*a)/(tan(1/2*a)^2 - 1) + 4 """ self.ex = ex From 551b3eb9818a2ff7b21dbcf430a56778a402cf65 Mon Sep 17 00:00:00 2001 From: nbruin Date: Tue, 6 Aug 2024 13:39:08 -0700 Subject: [PATCH 85/91] choose special name in absFactorize --- src/sage/rings/qqbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index c52a609e62a..4bbe281e8bf 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -981,7 +981,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): else: norm_f = numfield_f - R = norm_f._singular_().absFactorize() + R = norm_f._singular_().absFactorize('"_SAGE_ALGEBRAIC_"') singular.setring(R) L = singular('absolute_factors') From 42ae7697a05543353870c95b785df89313968d85 Mon Sep 17 00:00:00 2001 From: nbruin Date: Tue, 6 Aug 2024 14:21:43 -0700 Subject: [PATCH 86/91] no underscore at start of name --- src/sage/rings/qqbar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 4bbe281e8bf..a630479b44d 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -981,7 +981,7 @@ def _factor_multivariate_polynomial(self, f, proof=True): else: norm_f = numfield_f - R = norm_f._singular_().absFactorize('"_SAGE_ALGEBRAIC_"') + R = norm_f._singular_().absFactorize('"SAGE_ALGEBRAIC"') singular.setring(R) L = singular('absolute_factors') From 3b267f88b8b08b6c35384171b9c9c4aa6a66f58b Mon Sep 17 00:00:00 2001 From: nbruin Date: Tue, 6 Aug 2024 14:34:48 -0700 Subject: [PATCH 87/91] add doctest --- src/sage/rings/qqbar.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index a630479b44d..5d2f2ca2216 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -927,6 +927,15 @@ def _factor_multivariate_polynomial(self, f, proof=True): sage: # needs sage.libs.singular sage: AA['x','y'](1).factor() # indirect doctest 1 + + Test :issue:`#33327`:: + + sage: # needs sage.libs.singular + sage: S. = QQbar[] + sage: p = a^2 + 7*c^2 + sage: factor(p) + (a + (-2.645751311064591?*I)*c) * (a + 2.645751311064591?*I*c) + """ from sage.interfaces.singular import singular from sage.structure.factorization import Factorization From b67da0f4d0c524e17b663b855297896249b6c609 Mon Sep 17 00:00:00 2001 From: Giacomo Pope Date: Wed, 7 Aug 2024 09:45:08 +0100 Subject: [PATCH 88/91] allow compose_mod and modular_composition --- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 4 ++-- src/sage/rings/polynomial/polynomial_gf2x.pyx | 6 ++++++ .../rings/polynomial/polynomial_modn_dense_ntl.pyx | 14 +++++++++----- .../rings/polynomial/polynomial_zmod_flint.pyx | 13 +++++++++---- src/sage/rings/polynomial/polynomial_zz_pex.pyx | 12 ++++++++---- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 00db3039b3a..221e8d943f6 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -1472,7 +1472,7 @@ cdef class ntl_ZZ_pX(): #ZZ_pX_preallocate_space(&self.x, n) sig_off() - def modular_composition(self, ntl_ZZ_pX other, ntl_ZZ_pX modulus): + def compose_mod(self, ntl_ZZ_pX other, ntl_ZZ_pX modulus): r""" Compute `f(g) \pmod h`. @@ -1490,7 +1490,7 @@ cdef class ntl_ZZ_pX(): sage: f = ntl.ZZ_pX([1,2,3],c) sage: g = ntl.ZZ_pX([3,2,1],c) sage: h = ntl.ZZ_pX([1,0,1],c) - sage: f.modular_composition(g, h) + sage: f.compose_mod(g, h) [5 11] AUTHORS: diff --git a/src/sage/rings/polynomial/polynomial_gf2x.pyx b/src/sage/rings/polynomial/polynomial_gf2x.pyx index 9ba3727e3c0..cf4a224dda9 100644 --- a/src/sage/rings/polynomial/polynomial_gf2x.pyx +++ b/src/sage/rings/polynomial/polynomial_gf2x.pyx @@ -256,6 +256,12 @@ cdef class Polynomial_GF2X(Polynomial_template): verbose("Res %5.3f s"%cputime(t),level=1) return res + # Other polynomials have compose_mod as methods following the naming of + # NTL/Flint bindings but the above method predates these. We expose + # compose_mod here so all polynomial ring elements which support this can + # use either name + compose_mod = modular_composition + @cached_method def is_irreducible(self): r""" diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index 615379dc157..324cea2e4d9 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -424,7 +424,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): """ return small_roots(self, *args, **kwds) - def modular_composition(self, other, modulus): + def compose_mod(self, other, modulus): r""" Compute `f(g) \pmod h`. @@ -441,16 +441,16 @@ cdef class Polynomial_dense_mod_n(Polynomial): sage: R. = GF(2**127 - 1)[] sage: f = R.random_element() sage: g = R.random_element() - sage: g.modular_composition(g, f) == g(g) % f + sage: g.compose_mod(g, f) == g(g) % f True sage: R. = GF(163)[] sage: f = R([i for i in range(100)]) sage: g = R([i**2 for i in range(100)]) sage: h = 1 + x + x**5 - sage: f.modular_composition(g, h) + sage: f.compose_mod(g, h) 82*x^4 + 56*x^3 + 45*x^2 + 60*x + 127 - sage: f.modular_composition(g, h) == f(g) % h + sage: f.compose_mod(g, h) == f(g) % h True AUTHORS: @@ -460,9 +460,13 @@ cdef class Polynomial_dense_mod_n(Polynomial): elt = self.ntl_ZZ_pX() mod = modulus.ntl_ZZ_pX() other = other.ntl_ZZ_pX() - res = elt.modular_composition(other, mod) + res = elt.compose_mod(other, mod) return self.parent()(res, construct=True) + # compose_mod is the natural name from the NTL bindings, but polynomial_gf2x + # has modular_composition as the method name so here we allow both + modular_composition = compose_mod + def small_roots(self, X=None, beta=1.0, epsilon=None, **kwds): r""" diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx index e591aafc1df..adf826cfc71 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx @@ -990,7 +990,7 @@ cdef class Polynomial_zmod_flint(Polynomial_template): R = _single_variate(parent.base_ring(), name=name, implementation='NTL') return parent(R(self % other).minpoly_mod(R(other))) - def modular_composition(self, other, modulus): + def compose_mod(self, other, modulus): r""" Compute `f(g) \pmod h`. @@ -1007,15 +1007,15 @@ cdef class Polynomial_zmod_flint(Polynomial_template): sage: R. = GF(163)[] sage: f = R.random_element() sage: g = R.random_element() - sage: g.modular_composition(g, f) == g(g) % f + sage: g.compose_mod(g, f) == g(g) % f True sage: f = R([i for i in range(100)]) sage: g = R([i**2 for i in range(100)]) sage: h = 1 + x + x**5 - sage: f.modular_composition(g, h) + sage: f.compose_mod(g, h) 82*x^4 + 56*x^3 + 45*x^2 + 60*x + 127 - sage: f.modular_composition(g, h) == f(g) % h + sage: f.compose_mod(g, h) == f(g) % h True AUTHORS: @@ -1029,3 +1029,8 @@ cdef class Polynomial_zmod_flint(Polynomial_template): sig_off() return res + + # compose_mod is the natural name from the Flint bindings, but + # polynomial_gf2x has modular_composition as the method name so here we + # allow both + modular_composition = compose_mod diff --git a/src/sage/rings/polynomial/polynomial_zz_pex.pyx b/src/sage/rings/polynomial/polynomial_zz_pex.pyx index 20b59c2d3a2..6d00b066ddd 100644 --- a/src/sage/rings/polynomial/polynomial_zz_pex.pyx +++ b/src/sage/rings/polynomial/polynomial_zz_pex.pyx @@ -712,7 +712,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): sig_off() return r - def modular_composition(self, other, modulus): + def compose_mod(self, other, modulus): r""" Compute `f(g) \pmod h`. @@ -729,7 +729,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): sage: R. = GF(3**6)[] sage: f = R.random_element() sage: g = R.random_element() - sage: g.modular_composition(g, f) == g(g) % f + sage: g.compose_mod(g, f) == g(g) % f True sage: F. = GF(3**6) @@ -737,9 +737,9 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): sage: f = 2*z3^2*x^2 + (z3 + 1)*x + z3^2 + 2 sage: g = (z3^2 + 2*z3)*x^2 + (2*z3 + 2)*x + 2*z3^2 + z3 + 2 sage: h = (2*z3 + 2)*x^2 + (2*z3^2 + 1)*x + 2*z3^2 + z3 + 2 - sage: f.modular_composition(g, h) + sage: f.compose_mod(g, h) (z3^5 + z3^4 + z3^3 + z3^2 + z3)*x + z3^5 + z3^3 + 2*z3 + 2 - sage: f.modular_composition(g, h) == f(g) % h + sage: f.compose_mod(g, h) == f(g) % h True AUTHORS: @@ -771,3 +771,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): sig_off() return r + + # compose_mod is the natural name from the NTL bindings, but polynomial_gf2x + # has modular_composition as the method name so here we allow both + modular_composition = compose_mod From add73cbd4a488af46d3bec4ba5f1098d27e069fa Mon Sep 17 00:00:00 2001 From: Giacomo Pope <44242839+GiacomoPope@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:52:28 +0100 Subject: [PATCH 89/91] Apply suggestions from code review correct latex comments from code review Co-authored-by: Lorenz Panny <84067835+yyyyx4@users.noreply.github.com> --- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 4 ++-- src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx | 2 +- src/sage/rings/polynomial/polynomial_zmod_flint.pyx | 4 ++-- src/sage/rings/polynomial/polynomial_zz_pex.pyx | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 221e8d943f6..4082db003b4 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -1474,10 +1474,10 @@ cdef class ntl_ZZ_pX(): def compose_mod(self, ntl_ZZ_pX other, ntl_ZZ_pX modulus): r""" - Compute `f(g) \pmod h`. + Compute `f(g) \bmod h`. To be precise about the order fo compostion, given ``self``, ``other`` - and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \bmod h(x)`. INPUT: diff --git a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx index 324cea2e4d9..e91d4860b2d 100644 --- a/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx +++ b/src/sage/rings/polynomial/polynomial_modn_dense_ntl.pyx @@ -429,7 +429,7 @@ cdef class Polynomial_dense_mod_n(Polynomial): Compute `f(g) \pmod h`. To be precise about the order fo compostion, given ``self``, ``other`` - and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \bmod h(x)`. INPUT: diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx index adf826cfc71..3eaad290e09 100644 --- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx +++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx @@ -992,10 +992,10 @@ cdef class Polynomial_zmod_flint(Polynomial_template): def compose_mod(self, other, modulus): r""" - Compute `f(g) \pmod h`. + Compute `f(g) \bmod h`. To be precise about the order fo compostion, given ``self``, ``other`` - and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \bmod h(x)`. INPUT: diff --git a/src/sage/rings/polynomial/polynomial_zz_pex.pyx b/src/sage/rings/polynomial/polynomial_zz_pex.pyx index 6d00b066ddd..ec33846f2d9 100644 --- a/src/sage/rings/polynomial/polynomial_zz_pex.pyx +++ b/src/sage/rings/polynomial/polynomial_zz_pex.pyx @@ -714,10 +714,10 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): def compose_mod(self, other, modulus): r""" - Compute `f(g) \pmod h`. + Compute `f(g) \bmod h`. To be precise about the order fo compostion, given ``self``, ``other`` - and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \mod h(x)`. + and ``modulus`` as `f(x)`, `g(x)` and `h(x)` compute `f(g(x)) \bmod h(x)`. INPUT: From f2c4e22cb2babc159d2fe30173c8ef93c3bc7854 Mon Sep 17 00:00:00 2001 From: Lorenz Panny Date: Wed, 17 Apr 2024 15:13:36 +0200 Subject: [PATCH 90/91] expose fplll enumeration routines in IntegralLattice --- ...free_quadratic_module_integer_symmetric.py | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py index ab715bc57d5..c7473002448 100644 --- a/src/sage/modules/free_quadratic_module_integer_symmetric.py +++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py @@ -39,6 +39,7 @@ - Simon Brandhorst (2017-09): First created - Paolo Menegatti (2018-03): Added IntegralLatticeDirectSum, IntegralLatticeGluing +- Lorenz Panny (2024): enumeration routines for short and close vectors """ # **************************************************************************** @@ -1527,6 +1528,105 @@ def short_vectors(self, n, **kwargs): short = q.short_vector_list_up_to_length(n, *kwargs) return [[self(v * self.basis_matrix()) for v in L] for L in short] + def _fplll_enumerate(self, target=None): + r""" + Internal helper method to invoke the fplll enumeration routines. + + EXAMPLES:: + + sage: L = IntegralLattice('A4') + sage: t = vector([1.2, -3/11, 5.5, -9.1]) + sage: short = L.enumerate_short_vectors() # implicit doctest + sage: [next(short) for _ in range(10)] + [(0, 0, 0, 1), (0, 0, 1, 1), (0, 1, 1, 1), (1, 1, 1, 1), (0, 0, 1, 0), + (1, 1, 1, 0), (0, 1, 1, 0), (0, 1, 0, 0), (1, 1, 0, 0), (1, 0, 0, 0)] + sage: close = L.enumerate_close_vectors(t) # implicit doctest + sage: [next(close) for _ in range(10)] + [(1, 0, 6, -9), (1, -1, 5, -9), (2, 0, 6, -9), (1, 0, 5, -9), (1, -1, 5, -10), + (2, 1, 6, -9), (1, 0, 5, -10), (2, 0, 5, -9), (1, 0, 6, -8), (1, -1, 6, -9)] + """ + L = self.LLL() + dim = L.dimension() + gram = L.gram_matrix() + basis = L.basis_matrix() + + import fpylll + gmat = fpylll.IntegerMatrix(dim, dim) + for i in range(dim): + for j in range(dim): + gmat[i,j] = gram[i,j] + gso = fpylll.GSO.Mat(gmat, gram=True) + ok = gso.update_gso() + assert ok + + coord = None + if target is not None: + coord = basis.solve_left(target) + Mu = 1 + matrix([gso.get_mu(i,j) for j in range(dim)] for i in range(dim)) + coord *= Mu + + count = 8 + bound = gso.get_r(dim-1, dim-1) + seen = set() + while True: + enum = fpylll.Enumeration(gso, count, fpylll.EvaluatorStrategy.BEST_N_SOLUTIONS) + try: + combs = enum.enumerate(0, dim, bound, 0, coord) + except fpylll.EnumerationError: + combs = [] + if len(combs) < count: + bound *= 2 + continue + for length,comb in combs: + vec = sum(ZZ(c)*b for c,b in zip(comb,basis)) + if tuple(vec) not in seen: + yield vec + seen.add(tuple(vec)) + count *= 2 + + def enumerate_short_vectors(self): + r""" + Return an iterator over all the vectors in this lattice (modulo sign), + starting from shorter vectors. + + .. WARNING:: + + The returned vectors are not necessarily ordered strictly + by length. + + EXAMPLES:: + + sage: L = IntegralLattice(4, [[1,2,3,4], [7,7,8,8], [1,-1,1,0]]) + sage: short = L.enumerate_short_vectors() + sage: [next(short) for _ in range(20)] + [(1, -1, 1, 0), (2, -2, 2, 0), (3, -3, 3, 0), (0, 3, 2, 4), (1, 2, 3, 4), + (4, 4, 1, 0), (3, 2, -2, -4), (3, 5, 0, 0), (4, 1, -1, -4), (-1, 4, 1, 4), + (2, 1, 4, 4), (5, 3, 2, 0), (2, 3, -3, -4), (2, 6, -1, 0), (5, 0, 0, -4), + (-2, 5, 0, 4), (4, -4, 4, 0), (6, 2, 3, 0), (1, 4, -4, -4), (3, 0, 5, 4)] + """ + yield from self._fplll_enumerate() + + def enumerate_close_vectors(self, target): + r""" + Return an iterator over all the vectors in this lattice, starting + from vectors relatively close to the given ``target`` vector. + + .. WARNING:: + + The returned vectors are not necessarily ordered strictly + by their distance to the target. + + EXAMPLES:: + + sage: L = IntegralLattice(4, [[1,2,3,4], [7,7,8,8], [1,-1,1,0]]) + sage: t = vector([1/2, -133/7, 123.44, -11]) + sage: close = L.enumerate_close_vectors(t) + sage: [next(close) for _ in range(10)] + [(1, -18, 123, 148), (2, -19, 124, 148), (0, -17, 122, 148), (3, -20, 125, 148), (-1, -16, 121, 148), + (-2, -20, 125, 152), (-2, -23, 123, 148), (4, -21, 126, 148), (-3, -22, 122, 148), (-3, -19, 124, 152)] + """ + yield from self._fplll_enumerate(target) + def twist(self, s, discard_basis=False): r""" Return the lattice with inner product matrix scaled by ``s``. From e042294b5ed8e1cb564965079e20e4270ccde340 Mon Sep 17 00:00:00 2001 From: Release Manager Date: Sat, 10 Aug 2024 22:04:33 +0200 Subject: [PATCH 91/91] Updated SageMath version to 10.5.beta2 --- CITATION.cff | 4 ++-- VERSION.txt | 2 +- build/pkgs/configure/checksums.ini | 4 ++-- build/pkgs/configure/package-version.txt | 2 +- build/pkgs/sage_conf/version_requirements.txt | 2 +- build/pkgs/sage_docbuild/version_requirements.txt | 2 +- build/pkgs/sage_setup/version_requirements.txt | 2 +- build/pkgs/sage_sws2rst/version_requirements.txt | 2 +- build/pkgs/sagelib/version_requirements.txt | 2 +- build/pkgs/sagemath_bliss/version_requirements.txt | 2 +- build/pkgs/sagemath_categories/version_requirements.txt | 2 +- build/pkgs/sagemath_coxeter3/version_requirements.txt | 2 +- build/pkgs/sagemath_environment/version_requirements.txt | 2 +- build/pkgs/sagemath_mcqd/version_requirements.txt | 2 +- build/pkgs/sagemath_meataxe/version_requirements.txt | 2 +- build/pkgs/sagemath_objects/version_requirements.txt | 2 +- build/pkgs/sagemath_repl/version_requirements.txt | 2 +- build/pkgs/sagemath_sirocco/version_requirements.txt | 2 +- build/pkgs/sagemath_tdlib/version_requirements.txt | 2 +- pkgs/sage-conf/VERSION.txt | 2 +- pkgs/sage-conf_conda/VERSION.txt | 2 +- pkgs/sage-conf_pypi/VERSION.txt | 2 +- pkgs/sage-docbuild/VERSION.txt | 2 +- pkgs/sage-setup/VERSION.txt | 2 +- pkgs/sage-sws2rst/VERSION.txt | 2 +- pkgs/sagemath-bliss/VERSION.txt | 2 +- pkgs/sagemath-categories/VERSION.txt | 2 +- pkgs/sagemath-coxeter3/VERSION.txt | 2 +- pkgs/sagemath-environment/VERSION.txt | 2 +- pkgs/sagemath-mcqd/VERSION.txt | 2 +- pkgs/sagemath-meataxe/VERSION.txt | 2 +- pkgs/sagemath-objects/VERSION.txt | 2 +- pkgs/sagemath-repl/VERSION.txt | 2 +- pkgs/sagemath-sirocco/VERSION.txt | 2 +- pkgs/sagemath-tdlib/VERSION.txt | 2 +- src/VERSION.txt | 2 +- src/bin/sage-version.sh | 6 +++--- src/sage/version.py | 6 +++--- 38 files changed, 44 insertions(+), 44 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 53c25ca0bf4..bc17013072e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -4,8 +4,8 @@ title: SageMath abstract: SageMath is a free open-source mathematics software system. authors: - name: "The SageMath Developers" -version: 10.5.beta1 +version: 10.5.beta2 doi: 10.5281/zenodo.8042260 -date-released: 2024-08-03 +date-released: 2024-08-10 repository-code: "https://github.com/sagemath/sage" url: "https://www.sagemath.org/" diff --git a/VERSION.txt b/VERSION.txt index 274be67bb77..edf3563b259 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -SageMath version 10.5.beta1, Release Date: 2024-08-03 +SageMath version 10.5.beta2, Release Date: 2024-08-10 diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini index 836fb463900..69415aafab8 100644 --- a/build/pkgs/configure/checksums.ini +++ b/build/pkgs/configure/checksums.ini @@ -1,3 +1,3 @@ tarball=configure-VERSION.tar.gz -sha1=e7adc4b553577aa2ab6ab579a41457f37565b0ac -sha256=95e81e424da6a8abc43d74cf7270e27ff870ed753678c7c85434d7d2fa0ba6b0 +sha1=e162e0f52da5eca0c01ddf4831edcea1acd72033 +sha256=2033521228294e134368d69457d6e582706e84ff10bf3d6d0a57a2a4afad0a8b diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt index 476858b323a..2a5e3433ccb 100644 --- a/build/pkgs/configure/package-version.txt +++ b/build/pkgs/configure/package-version.txt @@ -1 +1 @@ -6e2716e9dcd0b6c06ffd847af708d29b0a63d6dd +b178c10a7401b381b8ed2daab5aaf026436452c9 diff --git a/build/pkgs/sage_conf/version_requirements.txt b/build/pkgs/sage_conf/version_requirements.txt index fbf395c98e6..a0d122e1756 100644 --- a/build/pkgs/sage_conf/version_requirements.txt +++ b/build/pkgs/sage_conf/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-conf ~= 10.5b1 +sage-conf ~= 10.5b2 diff --git a/build/pkgs/sage_docbuild/version_requirements.txt b/build/pkgs/sage_docbuild/version_requirements.txt index 0c940920163..b3dd5668f62 100644 --- a/build/pkgs/sage_docbuild/version_requirements.txt +++ b/build/pkgs/sage_docbuild/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-docbuild ~= 10.5b1 +sage-docbuild ~= 10.5b2 diff --git a/build/pkgs/sage_setup/version_requirements.txt b/build/pkgs/sage_setup/version_requirements.txt index 85a0b6283b4..bab577d27f2 100644 --- a/build/pkgs/sage_setup/version_requirements.txt +++ b/build/pkgs/sage_setup/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-setup ~= 10.5b1 +sage-setup ~= 10.5b2 diff --git a/build/pkgs/sage_sws2rst/version_requirements.txt b/build/pkgs/sage_sws2rst/version_requirements.txt index d79eba73f1f..e641cf4adc8 100644 --- a/build/pkgs/sage_sws2rst/version_requirements.txt +++ b/build/pkgs/sage_sws2rst/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sage-sws2rst ~= 10.5b1 +sage-sws2rst ~= 10.5b2 diff --git a/build/pkgs/sagelib/version_requirements.txt b/build/pkgs/sagelib/version_requirements.txt index 2e9ed0aa96a..086538d8f55 100644 --- a/build/pkgs/sagelib/version_requirements.txt +++ b/build/pkgs/sagelib/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-standard ~= 10.5b1 +sagemath-standard ~= 10.5b2 diff --git a/build/pkgs/sagemath_bliss/version_requirements.txt b/build/pkgs/sagemath_bliss/version_requirements.txt index 41b28ec9c42..3c1ecf4bcf2 100644 --- a/build/pkgs/sagemath_bliss/version_requirements.txt +++ b/build/pkgs/sagemath_bliss/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-bliss ~= 10.5b1 +sagemath-bliss ~= 10.5b2 diff --git a/build/pkgs/sagemath_categories/version_requirements.txt b/build/pkgs/sagemath_categories/version_requirements.txt index 48cf5febce5..4e081e476c4 100644 --- a/build/pkgs/sagemath_categories/version_requirements.txt +++ b/build/pkgs/sagemath_categories/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-categories ~= 10.5b1 +sagemath-categories ~= 10.5b2 diff --git a/build/pkgs/sagemath_coxeter3/version_requirements.txt b/build/pkgs/sagemath_coxeter3/version_requirements.txt index e0c16b0507c..f94c170af62 100644 --- a/build/pkgs/sagemath_coxeter3/version_requirements.txt +++ b/build/pkgs/sagemath_coxeter3/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-coxeter3 ~= 10.5b1 +sagemath-coxeter3 ~= 10.5b2 diff --git a/build/pkgs/sagemath_environment/version_requirements.txt b/build/pkgs/sagemath_environment/version_requirements.txt index 2bdfb3b446f..2915d669284 100644 --- a/build/pkgs/sagemath_environment/version_requirements.txt +++ b/build/pkgs/sagemath_environment/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-environment ~= 10.5b1 +sagemath-environment ~= 10.5b2 diff --git a/build/pkgs/sagemath_mcqd/version_requirements.txt b/build/pkgs/sagemath_mcqd/version_requirements.txt index b9886a71656..f066b99b596 100644 --- a/build/pkgs/sagemath_mcqd/version_requirements.txt +++ b/build/pkgs/sagemath_mcqd/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-mcqd ~= 10.5b1 +sagemath-mcqd ~= 10.5b2 diff --git a/build/pkgs/sagemath_meataxe/version_requirements.txt b/build/pkgs/sagemath_meataxe/version_requirements.txt index fdd34efcc57..ad91adb1087 100644 --- a/build/pkgs/sagemath_meataxe/version_requirements.txt +++ b/build/pkgs/sagemath_meataxe/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-meataxe ~= 10.5b1 +sagemath-meataxe ~= 10.5b2 diff --git a/build/pkgs/sagemath_objects/version_requirements.txt b/build/pkgs/sagemath_objects/version_requirements.txt index 449d1655cd5..e8b79dc7bb5 100644 --- a/build/pkgs/sagemath_objects/version_requirements.txt +++ b/build/pkgs/sagemath_objects/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-objects ~= 10.5b1 +sagemath-objects ~= 10.5b2 diff --git a/build/pkgs/sagemath_repl/version_requirements.txt b/build/pkgs/sagemath_repl/version_requirements.txt index f9dae843124..784aeb5cf8d 100644 --- a/build/pkgs/sagemath_repl/version_requirements.txt +++ b/build/pkgs/sagemath_repl/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-repl ~= 10.5b1 +sagemath-repl ~= 10.5b2 diff --git a/build/pkgs/sagemath_sirocco/version_requirements.txt b/build/pkgs/sagemath_sirocco/version_requirements.txt index b8946e45367..dcfccd36238 100644 --- a/build/pkgs/sagemath_sirocco/version_requirements.txt +++ b/build/pkgs/sagemath_sirocco/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-sirocco ~= 10.5b1 +sagemath-sirocco ~= 10.5b2 diff --git a/build/pkgs/sagemath_tdlib/version_requirements.txt b/build/pkgs/sagemath_tdlib/version_requirements.txt index 9db33c32f61..3f3d3da3740 100644 --- a/build/pkgs/sagemath_tdlib/version_requirements.txt +++ b/build/pkgs/sagemath_tdlib/version_requirements.txt @@ -1,2 +1,2 @@ # This file is updated on every release by the sage-update-version script -sagemath-tdlib ~= 10.5b1 +sagemath-tdlib ~= 10.5b2 diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sage-conf/VERSION.txt +++ b/pkgs/sage-conf/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sage-conf_conda/VERSION.txt +++ b/pkgs/sage-conf_conda/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sage-conf_pypi/VERSION.txt +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sage-docbuild/VERSION.txt +++ b/pkgs/sage-docbuild/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sage-setup/VERSION.txt +++ b/pkgs/sage-setup/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sage-sws2rst/VERSION.txt +++ b/pkgs/sage-sws2rst/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-bliss/VERSION.txt +++ b/pkgs/sagemath-bliss/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-categories/VERSION.txt +++ b/pkgs/sagemath-categories/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-coxeter3/VERSION.txt +++ b/pkgs/sagemath-coxeter3/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-environment/VERSION.txt +++ b/pkgs/sagemath-environment/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-mcqd/VERSION.txt +++ b/pkgs/sagemath-mcqd/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-meataxe/VERSION.txt +++ b/pkgs/sagemath-meataxe/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-objects/VERSION.txt +++ b/pkgs/sagemath-objects/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-repl/VERSION.txt +++ b/pkgs/sagemath-repl/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-sirocco/VERSION.txt +++ b/pkgs/sagemath-sirocco/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/pkgs/sagemath-tdlib/VERSION.txt +++ b/pkgs/sagemath-tdlib/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/src/VERSION.txt b/src/VERSION.txt index 0a338bc3255..c4777d00d87 100644 --- a/src/VERSION.txt +++ b/src/VERSION.txt @@ -1 +1 @@ -10.5.beta1 +10.5.beta2 diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh index c2f856c5a0f..92d914d9c6e 100644 --- a/src/bin/sage-version.sh +++ b/src/bin/sage-version.sh @@ -4,6 +4,6 @@ # which stops "setup.py develop" from rewriting it as a Python file. : # This file is auto-generated by the sage-update-version script, do not edit! -SAGE_VERSION='10.5.beta1' -SAGE_RELEASE_DATE='2024-08-03' -SAGE_VERSION_BANNER='SageMath version 10.5.beta1, Release Date: 2024-08-03' +SAGE_VERSION='10.5.beta2' +SAGE_RELEASE_DATE='2024-08-10' +SAGE_VERSION_BANNER='SageMath version 10.5.beta2, Release Date: 2024-08-10' diff --git a/src/sage/version.py b/src/sage/version.py index 75c2b3a8807..b9ae8e5a1c9 100644 --- a/src/sage/version.py +++ b/src/sage/version.py @@ -1,5 +1,5 @@ # Sage version information for Python scripts # This file is auto-generated by the sage-update-version script, do not edit! -version = '10.5.beta1' -date = '2024-08-03' -banner = 'SageMath version 10.5.beta1, Release Date: 2024-08-03' +version = '10.5.beta2' +date = '2024-08-10' +banner = 'SageMath version 10.5.beta2, Release Date: 2024-08-10'