-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Darwin, libgcc: Only build libemutls_w.a with shared #99
Darwin, libgcc: Only build libemutls_w.a with shared #99
Conversation
This would seem to be a good place to check this. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * g++.dg/pch/pch.exp: * gcc.dg/pch/pch.exp:
Tools from later versions of the OS deprecate or fail to support earlier OS revisions. libgcc/ * config.host: Arrange to set min Darwin OS versions from the configured host version. * config/i386/t-darwin: Amend to handle configured min OS versions. * config/t-darwin : Use the configured min OS versions. * config/t-darwin-min-1: New. * config/t-darwin-min-4: New. * config/t-darwin-min-5: New. * config/t-darwin-min-8: New.
This adds a configure option to allow a configurer to choose to build the compilers and other supporting tools as PIE. This is distinct from whether the compiler defaults to producing PIE code or not (i.e. one could have a PIE compiler producing non-PIE code by default, or vice-versa). Note that this implementation expects that the option will have been validated at the top-level before being passed to the gcc/ directory configure. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> config/ChangeLog: * mh-darwin: Note that shared (PIC) code is also needed to support PIE. gcc/ChangeLog: * Makefile.in: When pie-tools are enabled, do not add -no-PIE options to the compile and link lines. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Add --enable-pie-tools confingure option. t
This recognises and validates the --enable-pie-tools configure option. It is done here because the choice can affect the code- gen decisions for dependent libraries (e.g. in the case of Dariwn we need to switch PIC support on and, therefore, for 32bit tool- chains disable mdynamic-no-pic). The validated option is passed to sub-configures that use it (currently just gcc/). Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> ChangeLog: * Makefile.def: Pass enable-pie-tools configure option to gcc/ configure. * Makefile.in: Regenerated. * Makefile.tpl: Export enable_pie_tools value. * configure: Regenerate. * configure.ac: Add --enable-pie-tools option and validate it for Darwin.
This provides a spec to insert "-rpath DDD" for each DDD corresponding to a compiler startfile directory. This allows a target to use @rpath as the install path for libraries, and have the compiler provide the necessary rpath to handle this. gcc/ChangeLog: * gcc.c (RUNPATH_OPTION): New. (do_spec_1): Provide '%P' as a spec to insert rpaths for each compiler startfile path. Embed real paths, not relative ones. We embed a runpath for every path in which libraries might be found. This change ensures that we embed the actual real path and not a relative one from the compiler's version-specific directory. e.g. /opt/distro/gcc-11-3Dr0/lib instead of: /opt/distro/gcc-11-3Dr0/lib/gcc/x86_64-apple-darwin19/11.3.0/../../.. This ensures that if we install, for example, 11.4.0 (and delete the 11.3.0 installation) exes built by 11.3 would continue to function (providing, of course that 11.4 does not bump any SO names).
Recent Darwin versions place contraints on the use of run paths specified in environment variables. This breaks some assumptions in the GCC build. This change allows the user to configure a Darwin build to use '@rpath/libraryname.dylib' in library names and then to add an embedded runpath to executables (and libraries with dependents). The embedded runpath is added by default unless the user adds '-nodefaultrpaths' to the link line. For an installed compiler, it means that any executable built with that compiler will reference the runtimes installed with the compiler (equivalent to hard-coding the library path into the name of the library). During build-time configurations any "-B" entries will be added to the runpath thus the newly-built libraries will be found by exes. Since the install name is set in libtool, that decision needs to be available here (but might also cause dependent ones in Makefiles, so we need to export a conditional). This facility is not available for Darwin 8 or earlier, however the existing environment variable runpath does work there. We default this on for systems where the external DYLD_LIBRARY_PATH does not work and off for Darwin 8 or earlier. For systems that can use either method, if the value is unset, we use the default (which is currently DYLD_LIBRARY_PATH). ChangeLog: * configure: Regenerate. * configure.ac: Do not add default runpaths to GCC exes when we are building -static-libstdc++/-static-libgcc (the default). * libtool.m4: Add 'enable-darwin-at-runpath'. Act on the enable flag to alter Darwin libraries to use @rpath names. gcc/ChangeLog: * aclocal.m4: Regenerate. * configure: Regenerate. libatomic/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libcc1/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libffi/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libgcc/ChangeLog: * config/t-slibgcc-darwin: Generate libgcc_s with an @rpath name. libgfortran/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths libgomp/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libhsail-rt/ChangeLog: * configure: Regenerate. libitm/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libobjc/ChangeLog: * configure: Regenerate. * configure.ac: Handle Darwin rpaths. liboffloadmic/ChangeLog: * configure: Regenerate. * plugin/Makefile.in: Regenerate. * plugin/aclocal.m4: Regenerate. * plugin/configure: Regenerate. libphobos/ChangeLog: * configure: Regenerate. * libdruntime/Makefile.am: Handle Darwin rpaths. * libdruntime/Makefile.in: Regenerate. * src/Makefile.am: Handle Darwin rpaths. * src/Makefile.in: Regenerate. libquadmath/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Handle Darwin rpaths. libsanitizer/ChangeLog: * asan/Makefile.am: Handle Darwin rpaths. * asan/Makefile.in: Regenerate. * configure: Regenerate. * hwasan/Makefile.am: Handle Darwin rpaths. * hwasan/Makefile.in: Regenerate. * lsan/Makefile.am: Handle Darwin rpaths. * lsan/Makefile.in: Regenerate. * tsan/Makefile.am: Handle Darwin rpaths. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.am: Handle Darwin rpaths. * ubsan/Makefile.in: Regenerate. libssp/ChangeLog: * Makefile.am: Handle Darwin rpaths. * Makefile.in: Regenerate. * configure: Regenerate. libstdc++-v3/ChangeLog: * configure: Regenerate. * src/Makefile.am: Handle Darwin rpaths. * src/Makefile.in: Regenerate. Ada changes: add paths relative to @loader-path JIT changes: This patch expects DARWIN_RPATH to be computed and available; which means that we will use @rpath or ${libdir} as the name prefix depending on the system version and the setting of --enable-darwin-at-rpath. For branches that do not have this available, the value should be set to ${libdir}.
This is provided to allow distributions to add a single additional runpath to allow for cases where the installed GCC library director(y/ies) are then symlinked to a common dirctory outside of any of the GCC installations. For example: /opt/distro/lib: libgfortran.dylib -> /opt/distro/lib/gcc-11.3/lib/libgfortran.dylib So that libraries which are designed to be found in the runpath we would then add --with-darwin-add-rpath=/opt/distro/lib to the configure line. This patch makes the configuration a little more forgiving of using --disable-darwin-at-rpath (although for platform versions >= 10.11 this will result in misconfigured target libraries).
Base build changes to Darwin common code. It seems that the arm64 port will not make use of traditional mach-o pic but instead use a GOT - as such, the target-dependent parts of darwin.c are made NOP for this. We still expect to apply other Mach-O constraints. Most of the change is about the support for giving the user an error message when they try to invoke the compiler with multiple -arch flags. There is no provision in the initial port to handle the arm64_32 variant. This is (understood to be) only used in watchOS which we are not supporting initially. + No machopic indirections for Arm64 personality/LSDA entries. As for x86-64 (64bit code), the personality and LSDA .cfi_xxx entries do not require an indirection in the compiler code. + Accept arm64 in arch flags, for aarch64 compilers. We were checking for this and complaining if it was present for an X86 or PPC compiler, but we also need to accept (and ignore it) for an aarch64 / Arm64 compiler. This is enough to make a buildable cross-compiler on x86_64 Darwin and compile trivial codes. Although the link phase might not succeed - one can link objects manually and get an exe that works. There's an initial implementation of the rule changes for darwinpcs. There's an initial (pretty hacky) set of changes to deal with the post-fix assembly notation for Mach-O relocs. There are a few places where ELF was assumed, and we need to prevent incompatible output for Mach-O (probably there are other ways to do this). + Pick up atomic builtins from the libgcc.a CHECKME: should these be exported from the shared lib? (at present, that doesn't seem to be ideal). Look at what's done for the clang toolchain. + long double is DF not TF :( We will need to figure out what to do about supporting XXX*16 a some point. + Fix ptrdiff type. This was wrong (the size needs to track the 64-bitness and was failing to do so. + Add in driver sef-specs. Ensure that we issue the Darwin driver self specs and set the mabi and little-endian flags. clang accepts -mabi=darwinpcs so we allow that (but it means the same as lp64 at present since the target is determined at configuration time). + Fix an other build error for Darwin. Since we don't emit ELF function decorations this means that some of the variables are unused. + Initial implementation for EH without .cfi_xxxx While we can (most likely) make the .cfi_ codegen work, there are comments in the Ada code that suggest the capabilities of the unwinder are somewhat restricted. At least this option allows for the case of using libgcc_eh when an exe is self-contained. + Just whitespace fixes NFC. + We don't yet support TF, so reject 'q' suffix. The floating point literal suffix 'q' is specifically stated to be used for _float128, which we don't yet support. + Connect up the subtarget builtins i.e. __builtin_cfstring. The idea of OS-specific subtarget builtins doesn't fit too well with the general organisation of the aarch64 ones. What this does is to add it into the "GENERAL" class (but the darwin-specific code has no idea that the builtin code number has subfields). + Build fix for subtarget builtins. One either needs to define SUBTARGET_INIT_BUILTINS to empty or conditionalize its use + Connect up the sub-target attribute table. Darwin has some Mach-O / OS attributes, add these to the end of the aarch64 set.. + Connect up the pragma table. Darwin has some Mach-O / OS-specific pragmas, connected these to the end of the aarch64 table. gcc/ChangeLog: * config.gcc: Handle aarch64 and arm64 darwin. * config/aarch64/aarch64-protos.h (enum aarch64_symbol_type): Provide for symbol classifications for Mach-O. * config/aarch64/aarch64.c (aarch64_elf_asm_destructor): Don't define these for Mach-O (it's not ELF!). (handle_aarch64_vector_pcs_attribute): Handle darwinpcs. (aarch64_reg_save_mode): Likewise. (aarch64_load_symref_appropriately): Handle Mach-O. (aarch64_expand_mov_immediate): Likewise. (aarch64_layout_arg): Handle darwinpcs rules. (aarch64_function_arg): Likewise. (aarch64_init_cumulative_args): Likewise. (aarch64_function_arg_advance): Likewise. (aarch64_print_operand): Likewise (we can probably do better). (aarch64_print_address_internal): Likewise. (aarch64_asm_output_labelref): Likewise. (initialize_aarch64_code_model): Accept large PIC for Mach-O - of course, that doesn't mean it works. (aarch64_classify_symbol): Only emit ELF directives if they are available. (aarch64_declare_function_name): Likewise. (aarch64_asm_output_alias): Likewise. (aarch64_sls_emit_shared_blr_thunks): Likewise. (TARGET_ASM_UNALIGNED_HI_OP): New. (TARGET_ASM_UNALIGNED_SI_OP): New. (TARGET_ASM_UNALIGNED_DI_OP): New. * config/aarch64/aarch64.h (TARGET_MACHO): Declare as 0. (enum arm_pcs): Add darwinpcs. (SUBTARGET_EXTRA_SPECS): New. (EXTRA_SPECS): Allow for sub-target specs. * config/aarch64/aarch64.md (unspec enum): Add UNSPEC_MACHOPIC_OFFSET. (ldr_got_small_<mode>): Allow for postfix assembler syntax. (ldr_got_small_<mode>): Likewise. * config/aarch64/darwin.h: New file. * config/aarch64/t-aarch64-darwin: New file. Darwin, Arm64: Adjust NO_PIE spec for aarch64. Since aarch64 Darwin does not permit no-PIE, the linker warns that the option is ignored. Adjust the spec so that we do not send the option to the linker. gcc/ChangLog: * config/aarch64/darwin.h (DARWIN_NOPIE_SPEC): Revise for the aarch64 port. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> Darwin, Arm64 : Allow m64 on the command line. It seems that some people have makefiles etc. that put '-m64' for arm64 Darwin. This is allowed by clang. For the GCC version we make it an alias of -mabi=darwinpcs. aarch64, Darwin: Enable section anchors on -fsection-anchor. This is an experimental feature and might well require amendment to cater for constraints of the ld64 atom model. TODO: in supprot of that comment: 1. make the anchor base linker-visible 2. ensure that all offsets from that are local symbols. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/aarch64/darwin.h (TARGET_ASM_OUTPUT_ANCHOR, TARGET_USE_ANCHORS_FOR_SYMBOL_P, DARWIN_SECTION_ANCHORS): New. * config/aarch64/aarch64.c (aarch64_darwin_use_anchor_for_sym_p): Delete. (TARGET_USE_ANCHORS_FOR_SYMBOL_P): Delete. aarch64, Darwin: Ignore mdynamic-no-pic. Match the behaviour of clang in ignoring the setting of mdynamic-no-pic either on the command line or as an option to cc1. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> Darwin, Arm64 : Assign a register for the static chain. At present, we do not have a workable solution for trampolines for the Darwin Arm64 port. Executable stack is not an option and the advice from Arm is not to use any lower address bits to signal that we have a descriptor. It is possible that we might be able to load some remappable object (e.g. a dylib) - but the details there still have to be resolved. In any case, we need a usable static chain - and the port has that assigned to R18 by default - which is the platform register in darwinpcs. It's uncertain whether R16/R17 are actually used in the darwinpcs in the role of support for branch islanding. The AAPCS64 use as IP0/1 is conditional on ELF relocations, so perhaps irrelevant to Darwin. Using R16 does not conflict with the existing (non-functional) trampoline code. lots of TODOs here. aarch64, Darwin: Use darwin_binds_local_p for the target. We dind locally for PIC code (the default) on Darwin so that the default implementations will not work as expected. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/aarch64/darwin.h (TARGET_BINDS_LOCAL_P): New. Use darwin_bind_local_p() for this. aarhc64, Darwin: Do not give file-scope variables extra alignment. At lest, not until we determine the consequences of inter-operating with clang. Addresses Issue iains#68 Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/aarch64/darwin.h (DATA_ALIGNMENT): Just use the alignment of the underlying object for now. aarch64 : Cast print value per format description. Fixes a build fail. Darwin, Arm64 : Truncate char immediates in vector initializers to mode size. Darwin has signed chars, so that 8b immediates > 127 appear to be negative which produce large positive (out of assembler range) values when inspected by UINTVAL (). This patch truncates the values to the bitrange of the mode of the input. Fixes github issue 15. Darwin, Arm64 : Implement darwinpcs mangling for va_list. The darwinpcs says this must be mangled as char * (Pc) and not presented in the std:: namespace. aarch64, Darwin: Implement darwinpcs D.2 This allows us to pass items smaller than 8 bytes with their natural alignment packed as appropriate into the stack. This means that multiple args can use one AAPCS64 stack slot. We continue to account the stack in terms of words, but for darwinpcs the last word in the cumulative arguments is filled incrementally. So the allocation will remain 8-byte-wise, but the filling can be 1-byte aligned. This also means that darwinpcs needs to override the standard hook for TARGET_FUNCTION_ARG_ROUND_BOUNDARY. It turns out that trying to implement the Darwin PCS as CC variation is a can of worms and, since the target is chosen at configure time, not actually doing anything useful. Fallout from this included clobbering of callee saved regs etc. So - for now at least - back out of this and use the AAPCS64 as the darwinpcs, with the TARGET_MACHO flag chosing the variant. It is likely that we need to separate things more, since we haven't fully dealt with the variadic functions issue properly. Darwin, Arm64 : Additional change for darwincpcs D.4. We are allowed to pass 16bytes in regs even if the starting reg is not even-numbered. aarch64, Darwin: Adapt shared blr thunks for Darwin ABI. For Darwin we just emit the thunks as wek defintions. TODO: really we should emit this stuff before debug. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/aarch64/aarch64.c: Emit shared blr thunks as weak definitions. aarch64, Darwin: Initial support for relocations and asm syntax. At present, we are generating _foo+123@PAGE and we should have _foo@PAGE+123 etc. This can probably be fixed better with symbol flags and use of ASM_OUTPUT_SYMBOL_REF but that needs more work. Right now we're also stuck with GCC producing _foo@PAGE-1 as an example ... and the assmbler doesn't like it. Darwin, Arm64 : Make code label references use PAGE relocs We need to be able to refer to Lxxxx labels in libgnat. Darwin, Arm64 : Avoid negative offsets in PAGE relocs. It's not clear to me whether this is a mistake in the LLVM backend or a genuine restriction in the relocation (the wording of the addend reloc says neither 'signed' nor 'unsigned'. This works around this by making known negative offsets non-legitimate and composing the address by: ardp foo@PAGE add dest, temp, foo@PAGEOFF add dest, dest, neg_offset + We are now handling negative addends. Part of the code attempting to deal with the "PAGE-N" issue was to reject negative offsets in the legitimizers - actually, this wasn't effective anyway. We've now got code catching the cases and using a separate sum instruction, so delete these. aarch64, Darwin: Constrain page offset values to fit in the relocation. This fixes issue iains#52. We need to constrain the offsets in the @PAGE/@PAGEOFFS relocations to fit in a 24bit field - +/- 8Mb. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): If the offset will not fit into the relocation, then rewrite it as an addition. aarch64, Darwin: Account for UNSPEC_SALT_ADDR in symbol output. We were omitting the postfix relocation indicator because the code was falling back to the default output when a symbol was wrapped in an unspec SALT_ADDR. fixes issue iains#54. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> aarch64, Darwin: Allow for indexed address forms for PAGE+offset. We have been generating code like: adrp x0, sym@PAGE add x0, x0, sym@PAGEOFFS ld d0, [x0] now we generate: adrp x0, sym@PAGE ld d0 [x0, #sym@PAGEOFFS] and simmilarly for GOT accesses. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/aarch64/aarch64.c (aarch64_classify_address): Allow Mach-O PC relative accesses to constant pool and other defined objects. (aarch64_classify_symbol): Check for constant pool SYMREFs and only if it is not one check the Mach-O SYMBOL flags. aarch64, Darwin: Initial support for variadic function differences. These use the simpler char * version - but it remains to be seen if we need a non-standard rendition to cater for any amusing platform differences. Darwin, Arm64 : Adjust cases where stack spills pack differently. + Temporary handling for complex values. Complex values with a total size less than one stack slot might conceivably be packed in the same manner as other small values. However, this is not done - and we need to override the process for them. + Don't pack small structs either. Darwinpcs doesn't mention some things - and one is small structs. These are put into regs - but, when they spill to the stack, they don't pack in the manner of char, int et. al. + Handle HFA cases that have packed stack layout. bleah! (not sure this is complete). + Exclude unions from packing rule. + Hide an unused function. We are not using aarch64_vfp_is_call_candidate so wrap it in an #ifdef. + Fix a build error. Drop an unused var. Darwin, Arm64 : Account for stack addresses less aligned than DI. darwinpcs, packs some stack items, which means that one cannot guarantee that they are aligned to DI. Check for these cases and reject PRFM instructions then. Note, that this generally results in use of an extra temporary reg. clang uses 'PRFUM' instructions in those cases, so we have a missed optimisation opportunity (low priority). fixes issue iains#16. aarch64, Darwin: Handle prfm/prufm to support LLVM assemblers. 1. aarch64, Darwin : Restrict offsets for prfm. The current LLVM-based assemblers reject offsets that are not suitable for prfm as written in the local section. However, there is advice elsewhere that says that this category of instruction should attempt to use the 9bit unscaled version before falling back to the scaled one. In the short-term reject values that the assembler will not accept. This partially addresses Issue iains#43 gcc/ * config/aarch64/aarch64.c (aarch64_address_valid_for_prefetch_p): Reject values incompatible with pfrum and out of range for pfrm. For Mach-O, reject values that require prfum. 2. aarch64, Darwin : Match conditions for a PRFUM insn. This unpessimizes the prefetch cases for Darwin where the assembler is not able to substitute the prfum instructions automagically. This improves the fix for Issue iains#43. * config/aarch64/aarch64-protos.h * config/aarch64/aarch64.c * config/aarch64/aarch64.md * config/aarch64/constraints.md * config/aarch64/predicates.md Darwin, aarch64: Document the ABI (darwinpcs) and changes from that. Darwin,aarch64: Limit PAGE offsets to positive values for Darwin. Because of an assembler/linker bug, we cannot currently accept negative offset values for PAGEOFF relocations. While we were already catching this in expansion, there are cases where combine can produce values that need to be excluded. So reject symbol_refs with negative offsets.
…ayout and packing. 1. Generic : Mega-hack to allow different passing organisation for variadic funcs. Right now, the generic code assumes that it can determine the stack layout from target callbacks that don't have complete information about the argument they are processing (they only know the mode and the type - not it the argument is named or not, for example). This hack is not complete - but makes some progress. It looks like we really need the option for a target to override the layout process - if it requires distinct stack layouts for different calling convs. 2. Add cumulative_args_t variants of TARGET_FUNCTION_ROUND_BOUNDARY and friends The two target hooks responsible for informing GCC about stack parameter alignment are `TARGET_FUNCTION_ARG_BOUNDARY` and `TARGET_FUNCTION_ARG_ROUND_BOUNDARY`, which currently only consider the tree and machine_mode of a specific given argument. Create two new target hooks suffixed with '_CA', and pass in a third `cumulative_args_t` parameter. This enables the backend to make alignment decisions based on the context of the whole function rather than individual parameters. The orignal machine_mode/tree type macros are not removed - they are called by the default implementations of `TARGET_...BOUNDARY_CA` and `TARGET_...ROUND_BOUNDARY_CA`. This is done with the intetnion of avoiding large mechanical modifications of nearly every backend in GCC. There is also a new flag, -fstack-use-cumulative-args, which provides a way to completely bypass the new `..._CA` macros. This feature is intended for debugging GCC itself. gcc/ChangeLog: * calls.c (initialize_argument_information): Pass `args_so_far`. * common.opt: New flag `-fstack-use-cumulative-args`. * config.gcc: No platforms currently use ..._CA-hooks: Set -fstack-use-cumulative-args to be off by default. * target.h (cumulative_args_t): Move declaration from here, to... * cumulative-args.h (cumulative_args_t): ...this new file. This is to permit backends to include the declaration of cumulative_args_t without dragging in circular dependencies. * function.c (assign_parm_find_entry_rtl): Provide cumulative_args_t to locate_and_pad_parm. (gimplify_parameters): Ditto. (locate_and_pad_parm): Conditionally call new hooks if we're invoked with -fstack-use-cumulative-args. * function.h: Include cumulative-args.h. (locate_and_pad_parm): Add cumulative_args_t parameter. * target.def (function_arg_boundary_ca): Add. (function_arg_round_boundary_ca): Ditto. * targhooks.c (default_function_arg_boundary_ca): Implement. (default_function_arg_round_boundary_ca): Ditto. * targhooks.h (default_function_arg_boundary_ca): Declare. (default_function_arg_round_boundary_ca): Ditto. * doc/invoke.texi (-fstack-use-cumulative-args): Document. * doc/tm.texi: Regenerate. * doc/tm.texi.in: Ditto. 3. Implement TARGET_..._CA target hooks for AArch64 Darwin The AArch64 Darwin platform requires that named stack arguments are passed naturally-aligned, while variadic stack arguments are passed on word boundaries. Use the TARGET_FUNCTION_ARG_BOUNDARY_CA and TARGET_FUNCTION_ARG_ROUND_BOUNDARY_CA target hooks to let the backend correctly layout stack parameters. gcc/ChangeLog: * config.gcc: Enable -fstack-use-cumulative-args by default if the host platform is MacOS 11.x or 12.x and we're on AArch64. gcc/config/aarch64/ChangeLog: * aarch64-protos.h (aarch64_init_cumulative_incoming_args): Declare. * aarch64.c (aarch64_init_cumulative_args): Initialize `darwinpcs_n_named` (Total number of named parameters) and `darwinpcs_n_args_processed` (Total number of parameters we have processed, including variadic if any.) (aarch64_init_cumulative_incoming_args): Implement the INIT_CUMULATIVE_INCOMING_ARGS macro in order to capture information on the number of named parameters for the current function. (aarch64_function_arg_advance): Increment `darwinpcs_n_args_processed` each time we layout a function parameter. (aarch64_function_arg_boundary_ca): Implement TARGET_FUNCTION_ARG_BOUNDARY_CA and TARGET_FUNCTION_ARG_ROUND_BOUNDARY_CA to layout args based on whether we're a named parameter or not. (aarch64_function_arg_round_boundary_ca): Ditto. (TARGET_FUNCTION_ARG_BOUNDARY_CA): Define. (TARGET_FUNCTION_ARG_ROUND_BOUNDARY_CA): Ditto. * aarch64.h (CUMULATIVE_ARGS): Add `darwinpcs_n_named` and `darwinpcs_n_args_processed`. (INIT_CUMULATIVE_INCOMING_ARGS): Define. 3. aarch64, Darwin: Rework varargs handling to use cumulative args. Maybe incomplete. Currently this builds the information twice once during arg layout and once during the value lookup - and checks we get the same result - looking for any asserts before we enable the simplified version. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config.gcc: * config/aarch64/aarch64.c (aarch64_layout_arg): (aarch64_init_cumulative_args): (aarch64_function_arg_boundary_ca): (aarch64_function_arg_round_boundary_ca): (aarch64_setup_incoming_varargs): * config/aarch64/aarch64.h:
1. libgcc, aarch64, Darwin: Initial libgcc boiler-plate changes. Initial changes to build libgcc for aarch64 Darwin (declare the port, handle Mach-O assembler syntax and arrange for building the main extra pieces). 2. libgcc, aarch64, Darwin: Do not build legacy EH shim. Darwin aarch64 does not exist for macOS 10.6, so there is no need to build a shim to target it. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> libgcc/ * config.host: Omit the Darwin10 unwinder shim for aarch64 Darwin. 3. libgcc, aarch64, Darwin: Darwin should use an OS call to clear caches. The sys_icache_invalidate() function is the right one to use. The fixes issue iains#17 4. libgcc, aarch64, Darwin: Enable heap trampolines.
1. Darwin has a C long double type which is the same as the double. In order to support a higher precision floating point type, define __float128 (which will automatically make _Float128 available to C). Co-authored-by: Iain Sandoe <iain@sandoe.co.uk> 2. aarch64, Darwin: Amend float128 additions to correct max_align_t. The alignment of floating types is tested in two places, one internal to GCC and in the stddef header. The first checks the global float128_type_node so we should assign our decl to that node. For the second, the simple approach is to special case the Darwin aarch64 port (in addition to i386). TODO: see if there is a more generic way to do this. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/aarch64/aarch64-builtins.c (aarch64_init_float128_types): * config/aarch64/aarch64.c (aarch64_gimplify_va_arg_expr): * config/aarch64/aarch64.h (GTY): * ginclude/stddef.h (defined):
Just add Arm64 as a target and adjust the SjLj code to allow mach-o assembler.
testsuite, Darwin, Arm64 : Darwin does not support sve at present. Not clear if it will in future. testsuite, Darwin, Arm64 : Fixup tests where the output is different. It's to be expected that the output from scan assembler tests will vary for Darwin - since the object format, assembler syntax and ABI all have differences from ELF/AAPCS64. testsuite, Darwin, Arm64 : Fix up CFString tests for arm64 asm. The codegen tests include scan asms for the required output - these need adjustment for the Arm64 assembler syntax. testsuite, Darwin, Arm64 : Amend segaddr test. The target does not accept no-pie, so we must not try it. testsuite, Darwin, Arm64 : Adjust pubtypes lengths for Arm64. This differs from other Darwin targets CHECKME. testsuite, Darwin, Arm64 : Adjust for revised section spellings. We fixed some section names to change __common -> __bss which affects this testcase. testsuite, Darwin, Arm64 : Disable the AAPCS64 tests. These are not appropriate for darwinpcs / Mach-O. For now, we have compat.exp and struct-layout-1.exp as some coverage, but ideally we should have some specific ones (perhaps some of the AAPCS64 ones can be adapted). testsuite, Darwin, Arm64 : Add U_L_P to bf16 mangling test. gcc/testsuite/ChangeLog * g++.dg/ext/arm-bf16/bf16-mangle-aarch64-1.C: Adjust scan- asms to allow for USER_LABEL_PREFIX and Darwin assembler syntax. testsuite, Darwin, Arm64 : Amend scan-asms for arm syntax. Adjust some objective C tests. testsuite, Darwin, Arm64 : Skip tests with an unsupported API. The "OBJC_OLD_DISPATCH_PROTOTYPES" workaround is explicitly disabled for arm64 in the system headers. testsuite, Darwin, Arm64 : Skip tests with an unsupported API. The "OBJC_OLD_DISPATCH_PROTOTYPES" workaround is explicitly disabled for arm64 in the system headers. testsuite, Objective-C, Darwin, Arm64 : adjust scan-asms for arm64. We need to pick up xword and word instead of quad and long. testsuite, Darwin, Arm64 : Skip two unsupported tests. The compare function bodies code is ELF-specific at present skip the tests until we can make a Mach-O version. gcc/testsuite/ChangeLog: * g++.target/aarch64/no_unique_address_1.C: Skip. * g++.target/aarch64/no_unique_address_2.C: Skip. testsuite, Darwin, Arm64 : Skip more tests using 'check-function-bodies'. The implementation for check-function-bodies doesn't support Mach-O at this point - so this is justy noise. TODO: provide a Mach-O version of the scan asm function. testsuite, Darwin: Amendments for Darwin >= 20. gcc/testsuite/ChangeLog: * gcc.dg/torture/stackalign/builtin-apply-2.c: * lib/target-libpath.exp: Misc test fixes testsuite, Darwin, Arm64: Do not pass -mcmodel=large Testsuite, aarch64: Add correct requirements for bf16 and i8mm gcc/testsuite/ChangeLog: * gcc.target/aarch64/advsimd-intrinsics/bf16_dup.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bf16_get.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bf16_reinterpret.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bfcvt-compile.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bfcvtnq2-untied.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bfdot-1.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bfmlalbt-compile.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/bfmmla-compile.c: Require aarch64_asm_bf16_ok. * gcc.target/aarch64/advsimd-intrinsics/vdot-3-1.c: Require arm_v8_2a_i8mm_neon_hw. testsuite, Darwin, aarch64: Initial mach-o support for check-function-bodies. The scanning code for the function regexes needs different delination criteria for Mach-O c.f. ELF. Darwin also uses the __USER_LABEL_PREFIX__ of '_' which needs acconting in both the scanning and matching patterns. When the code involves page/pageoffs then it is probably necessary to have a separate match for Darwin in some cases. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/cpymem-size.c: * gcc.target/aarch64/memset-corner-cases-2.c: * gcc.target/aarch64/memset-corner-cases.c: * gcc.target/aarch64/vect-cse-codegen.c: * lib/scanasm.exp: testsuite, Darwin, aarch64: No .cfi_ instruction support on Darwin yet. We have to skip tests for frame instructions at present until the issues with compact unwind support for GCC are resolved. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/stack-check-cfa-1.c: Skip for Darwin. * gcc.target/aarch64/stack-check-cfa-2.c: Likewise. * gcc.target/aarch64/stack-check-cfa-3.c: Likewise. testsuite, Darwin, aarch64: Match Darwin codegen for aligned object. Darwin uses .zerofill instructions for these. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/arm_align_max_pwr.c: Match .zerofill on Darwin. testsuite, Darwin, aarch64: More simple test fixes. A few more that just need trivial adjustments for Darwin codegen or asm syntax. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/c-output-template-2.c: * gcc.target/aarch64/c-output-template-3.c: * gcc.target/aarch64/c-output-template-4.c: * gcc.target/aarch64/dwarf-cfa-reg.c: * gcc.target/aarch64/symbol-range-tiny.c: * gcc.target/aarch64/uaddw-3.c: make the mach-o function scan a bit more robust testsuite, Darwin, aarch64: Update tests after address logic change Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/vect-cse-codegen.c: * gcc.target/aarch64/darwin/darwin.exp: New test. * gcc.target/aarch64/darwin/tu-accesses-0.c: New test. another test fix testsuite, Darwin, aarch64: Skip variant_pcs tests. The __simd__ attribute is not accepted by clang and there is no current description of whether variant CCs would be allowed (I did not see them when last I looked at the LLVM aarch64 darwin call lowering). Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/simd_pcs_attribute-2.c: Skip for Darwin. * gcc.target/aarch64/simd_pcs_attribute-3.c: Likewise. * gcc.target/aarch64/simd_pcs_attribute.c: Likewise. testsuite, Darwin, aarch64: Amend more tests to work on both Linux and Darwin. Darwin does not support big-endian and has a signed char. gcc/testsuite/ChangeLog: * gcc.dg/rtl/aarch64/big-endian-cse-1.c: * gcc.target/aarch64/auto-init-2.c: * gcc.target/aarch64/auto-init-3.c: * gcc.target/aarch64/auto-init-4.c: * gcc.target/aarch64/auto-init-5.c: * gcc.target/aarch64/auto-init-6.c: * gcc.target/aarch64/inline-lrint_1.c: * gcc.target/aarch64/ldp_stp_13.c: * gcc.target/aarch64/no-inline-lrint_1.c: * gcc.target/aarch64/pr100518.c: * gcc.target/aarch64/pr80295.c: * gcc.target/aarch64/pr87305.c: * gcc.target/aarch64/pr94201.c: * gcc.target/aarch64/pr94577.c: * lib/target-supports.exp: * gcc.target/aarch64/pr62308.c: * gcc.target/aarch64/pr78255.c: * gcc.target/aarch64/pr78561.c: testsuite, aarch64, Darwin: Re-enable some scan-function-body tests. Now we have rudimentary support, some of the tests can be renabled. testsuite, Darwin, aarch64: Add a test for darwinpcs d.4. We should not skip registers in the case that we have a 128n value to pass starting on an odd register number. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/darwin/darwin.exp: Moved to... * gcc.target/aarch64/darwin/aarch64-darwin.exp: ...here. * gcc.target/aarch64/darwin/darwinpcs-d4.c: New test. testsuite, Darwin, aarch64: Initial tests for darwinpcs D2. Tests of packing of small items (char, short, int). Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/darwin/darwinpcs-d2-00.c: New test. * gcc.target/aarch64/darwin/darwinpcs-d2-01.c: New test. testsuite, Darwin, aarch64: Add more tests for darwinpcs. This covers the main four points and initial exercising of variadic function calls. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/testsuite/ChangeLog: * gcc.target/aarch64/darwin/darwinpcs-d2-00.c: * gcc.target/aarch64/darwin/darwinpcs-d2-01.c: * gcc.target/aarch64/darwin/darwinpcs-d4.c: * gcc.target/aarch64/darwin/tu-accesses-0.c: * gcc.target/aarch64/darwin/complex-in-regs.c: New test. * gcc.target/aarch64/darwin/darwinpcs-d1.c: New test. * gcc.target/aarch64/darwin/darwinpcs-d2-02.c: New test. * gcc.target/aarch64/darwin/darwinpcs-d2-03.c: New test. * gcc.target/aarch64/darwin/darwinpcs-d2-04.c: New test. * gcc.target/aarch64/darwin/darwinpcs-d3.c: New test. * gcc.target/aarch64/darwin/homogeneous-aggr.c: New test. * gcc.target/aarch64/darwin/variadic-00.c: New test. Testsuite: Adjust a Fortran error check gcc/testsuite/ChangeLog * gfortran.dg/pr95690.f90: Adjust error check on aarch64-apple-darwin. Testsuite: skip test gcc/testsuite/ChangeLog: * gcc.dg/builtin-apply2.c: Skip on aarch64-apple-darwin because normal and variadic functions use different arg passing. Testsuite: Fix patterns on stdarg-based tests gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/stdarg-2.c: Adjust pattern. * gcc.dg/tree-ssa/stdarg-4.c: Adjust pattern. * gcc.dg/tree-ssa/stdarg-5.c: Adjust pattern.
Just some top level information on this specific branch.
The 12.2r0 release includes a fix that correctly passes options through to libtool (previously they were siliently ignored). One of the options concerned was "-nodefaultexport" which suppresses the automatic addition of emulated TLS symbols to dylibs and modules. Unfortunately, this bug-fix now means that some of the runtimes no longer re-export the emulated TLS symbols and, therefore, existing code that happened to link to those will not find the symbols (even though, of course they are present in libgcc_s.) This patch drops the '-nodefaultexport' from the libtool lines, so that once again (albeit incorrectly) the libraries concerned re-export the symbols from libgcc_s. Since the emulated TLS implementations are all weak, this should not cause any actual runtime issue, it is just unfortunate and untidy.
I understand the problem you are describing, but this patch cannot be the right solution (libemutls_w.a is a necessary component) so that the solution needed is to adjust the dependencies for libemutls_w.a so that it depends on emutls_s.o for shared and emutls.o for non-shared. Actually, for most Darwin/macOS cases, it makes no sense to --disable-shared, since macOS always uses PIC code (sole exception is -mdynamic-no-pic on earlier versions). So it does not make the code any smaller or faster to "--disable-shared". |
Thanks for the clarification! The downstream usecase in nixpkgs is to build a standalone version of libgcc from the gcc tree to simplify bootstrapping. If Maybe @Ericson2314 have something to add? The context is NixOS/nixpkgs#196565. |
I am a bit puzzled .. All macOS user-space applications are built against libSystem.dylib (there is no such thing as a "static" user-space program) so that having libgcc_s.1{.1.}dylib built against it should make no difference? What version of OSX / macOS are you targeting here? |
We have recently fixed a long-term issue with libgcc by splitting the handling of the builtins, emulated TLS support and EH handling into separate parts. libgcc.a contains the builtins (convenience library) libgcc_s.1.1.dylib contains a shared version of the builtins + the emulated TLS support. There is an unwinder in Those (unwinder libs) should almost never be used, since that defeats the ability to unwind through system libraries and they are no needed since the unwinder is supplied by /usr/lib/libgcc_s.1.dylib (10.4/5) or libSystem.dylib (10.6+) We do build a libgcc_s.1.dylib (on powerpc and x86) which forwards libgcc_s.1.1.dylib and the unwinder, this is not needed for any new code built with current GCC, it is provided only as a compatibility library for existing exes. (minor edits to clarify a couple of points) |
398c061
to
5760d3a
Compare
31e3927
to
d679055
Compare
d679055
to
7bb7023
Compare
7bb7023
to
5b9ed5b
Compare
d2d9459
to
e9ecaec
Compare
e9ecaec
to
3d071a5
Compare
3d071a5
to
31499d1
Compare
5160f5b
to
8eaa8e7
Compare
Yeah, I was hoping that by pinging @zhaofengli, I/we could get an update from him about the remaining issues with this PR, but, I guess no such luck... I'd say if we don't hear anything from him in like another 3 months or so, then I'd just close this. |
4f91325
to
9bc66f9
Compare
9bc66f9
to
56778f8
Compare
c0da5b8
to
85e919d
Compare
8b38cd2
to
b0b8a39
Compare
b0b8a39
to
4121c06
Compare
b5cb04a
to
294ce24
Compare
977c2da
to
d00f13b
Compare
3763ff8
to
9c8c56d
Compare
9c8c56d
to
b9ffb77
Compare
e2e8042
to
78a1897
Compare
47060a2
to
88c8a50
Compare
OK so yeah, I think it's time to close this now. |
Sorry all, it's been a while and I've lost context on the PR. It's likely not needed and can be closed. |
This patch skips building
libemutls_w.a
if shared libraries are disabled, becauselibemutls_w.a
depends onemutls_s.o
.