110d565efSmrg /* Definitions for systems using the Linux kernel, with or without 210d565efSmrg MMU, using ELF at the compiler level but possibly FLT for final 310d565efSmrg linked executables and shared libraries in some no-MMU cases, and 410d565efSmrg possibly with a choice of libc implementations. 5*ec02198aSmrg Copyright (C) 1995-2020 Free Software Foundation, Inc. 610d565efSmrg Contributed by Eric Youngdale. 710d565efSmrg Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org). 810d565efSmrg 910d565efSmrg This file is part of GCC. 1010d565efSmrg 1110d565efSmrg GCC is free software; you can redistribute it and/or modify 1210d565efSmrg it under the terms of the GNU General Public License as published by 1310d565efSmrg the Free Software Foundation; either version 3, or (at your option) 1410d565efSmrg any later version. 1510d565efSmrg 1610d565efSmrg GCC is distributed in the hope that it will be useful, 1710d565efSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of 1810d565efSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1910d565efSmrg GNU General Public License for more details. 2010d565efSmrg 2110d565efSmrg Under Section 7 of GPL version 3, you are granted additional 2210d565efSmrg permissions described in the GCC Runtime Library Exception, version 2310d565efSmrg 3.1, as published by the Free Software Foundation. 2410d565efSmrg 2510d565efSmrg You should have received a copy of the GNU General Public License and 2610d565efSmrg a copy of the GCC Runtime Library Exception along with this program; 2710d565efSmrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2810d565efSmrg <http://www.gnu.org/licenses/>. */ 2910d565efSmrg 3010d565efSmrg /* C libraries supported on Linux. */ 3110d565efSmrg #ifdef SINGLE_LIBC 3210d565efSmrg #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) 3310d565efSmrg #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) 3410d565efSmrg #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) 3510d565efSmrg #undef OPTION_MUSL 3610d565efSmrg #define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) 3710d565efSmrg #else 3810d565efSmrg #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) 3910d565efSmrg #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) 4010d565efSmrg #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) 4110d565efSmrg #undef OPTION_MUSL 4210d565efSmrg #define OPTION_MUSL (linux_libc == LIBC_MUSL) 4310d565efSmrg #endif 4410d565efSmrg 4510d565efSmrg #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ 4610d565efSmrg do { \ 4710d565efSmrg if (OPTION_GLIBC) \ 4810d565efSmrg builtin_define ("__gnu_linux__"); \ 4910d565efSmrg builtin_define_std ("linux"); \ 5010d565efSmrg builtin_define_std ("unix"); \ 5110d565efSmrg builtin_assert ("system=linux"); \ 5210d565efSmrg builtin_assert ("system=unix"); \ 5310d565efSmrg builtin_assert ("system=posix"); \ 5410d565efSmrg } while (0) 5510d565efSmrg 560fc04c29Smrg #define GNU_USER_TARGET_D_OS_VERSIONS() \ 570fc04c29Smrg do { \ 580fc04c29Smrg builtin_version ("linux"); \ 590fc04c29Smrg if (OPTION_GLIBC) \ 600fc04c29Smrg builtin_version ("CRuntime_Glibc"); \ 610fc04c29Smrg else if (OPTION_UCLIBC) \ 620fc04c29Smrg builtin_version ("CRuntime_UClibc"); \ 630fc04c29Smrg else if (OPTION_BIONIC) \ 640fc04c29Smrg builtin_version ("CRuntime_Bionic"); \ 650fc04c29Smrg else if (OPTION_MUSL) \ 660fc04c29Smrg builtin_version ("CRuntime_Musl"); \ 670fc04c29Smrg } while (0) 680fc04c29Smrg 6910d565efSmrg /* Determine which dynamic linker to use depending on whether GLIBC or 7010d565efSmrg uClibc or Bionic or musl is the default C library and whether 7110d565efSmrg -muclibc or -mglibc or -mbionic or -mmusl has been passed to change 7210d565efSmrg the default. */ 7310d565efSmrg 7410d565efSmrg #define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ 7510d565efSmrg "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" 7610d565efSmrg 7710d565efSmrg #if DEFAULT_LIBC == LIBC_GLIBC 7810d565efSmrg #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ 7910d565efSmrg CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) 8010d565efSmrg #elif DEFAULT_LIBC == LIBC_UCLIBC 8110d565efSmrg #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ 8210d565efSmrg CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) 8310d565efSmrg #elif DEFAULT_LIBC == LIBC_BIONIC 8410d565efSmrg #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ 8510d565efSmrg CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) 8610d565efSmrg #elif DEFAULT_LIBC == LIBC_MUSL 8710d565efSmrg #define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ 8810d565efSmrg CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) 8910d565efSmrg #else 9010d565efSmrg #error "Unsupported DEFAULT_LIBC" 9110d565efSmrg #endif /* DEFAULT_LIBC */ 9210d565efSmrg 9310d565efSmrg /* For most targets the following definitions suffice; 9410d565efSmrg GLIBC_DYNAMIC_LINKER must be defined for each target using them, or 9510d565efSmrg GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets 9610d565efSmrg supporting both 32-bit and 64-bit compilation. */ 9710d565efSmrg #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" 9810d565efSmrg #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" 9910d565efSmrg #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" 10010d565efSmrg #define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0" 10110d565efSmrg #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" 10210d565efSmrg #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" 10310d565efSmrg #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" 10410d565efSmrg #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32" 10510d565efSmrg /* Should be redefined for each target that supports musl. */ 10610d565efSmrg #define MUSL_DYNAMIC_LINKER "/dev/null" 10710d565efSmrg #define MUSL_DYNAMIC_LINKER32 "/dev/null" 10810d565efSmrg #define MUSL_DYNAMIC_LINKER64 "/dev/null" 10910d565efSmrg #define MUSL_DYNAMIC_LINKERX32 "/dev/null" 11010d565efSmrg 11110d565efSmrg #define GNU_USER_DYNAMIC_LINKER \ 11210d565efSmrg CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ 11310d565efSmrg BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) 11410d565efSmrg #define GNU_USER_DYNAMIC_LINKER32 \ 11510d565efSmrg CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ 11610d565efSmrg BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) 11710d565efSmrg #define GNU_USER_DYNAMIC_LINKER64 \ 11810d565efSmrg CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ 11910d565efSmrg BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) 12010d565efSmrg #define GNU_USER_DYNAMIC_LINKERX32 \ 12110d565efSmrg CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ 12210d565efSmrg BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32) 12310d565efSmrg 12410d565efSmrg /* Whether we have Bionic libc runtime */ 12510d565efSmrg #undef TARGET_HAS_BIONIC 12610d565efSmrg #define TARGET_HAS_BIONIC (OPTION_BIONIC) 12710d565efSmrg 12810d565efSmrg /* musl avoids problematic includes by rearranging the include directories. 12910d565efSmrg * Unfortunately, this is mostly duplicated from cppdefault.c */ 13010d565efSmrg #if DEFAULT_LIBC == LIBC_MUSL 13110d565efSmrg #define INCLUDE_DEFAULTS_MUSL_GPP \ 13210d565efSmrg { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ 13310d565efSmrg GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ 13410d565efSmrg { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ 13510d565efSmrg GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ 13610d565efSmrg { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ 13710d565efSmrg GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, 13810d565efSmrg 13910d565efSmrg #ifdef LOCAL_INCLUDE_DIR 14010d565efSmrg #define INCLUDE_DEFAULTS_MUSL_LOCAL \ 14110d565efSmrg { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ 14210d565efSmrg { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, 14310d565efSmrg #else 14410d565efSmrg #define INCLUDE_DEFAULTS_MUSL_LOCAL 14510d565efSmrg #endif 14610d565efSmrg 14710d565efSmrg #ifdef PREFIX_INCLUDE_DIR 14810d565efSmrg #define INCLUDE_DEFAULTS_MUSL_PREFIX \ 14910d565efSmrg { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, 15010d565efSmrg #else 15110d565efSmrg #define INCLUDE_DEFAULTS_MUSL_PREFIX 15210d565efSmrg #endif 15310d565efSmrg 15410d565efSmrg #ifdef CROSS_INCLUDE_DIR 15510d565efSmrg #define INCLUDE_DEFAULTS_MUSL_CROSS \ 15610d565efSmrg { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, 15710d565efSmrg #else 15810d565efSmrg #define INCLUDE_DEFAULTS_MUSL_CROSS 15910d565efSmrg #endif 16010d565efSmrg 16110d565efSmrg #ifdef TOOL_INCLUDE_DIR 16210d565efSmrg #define INCLUDE_DEFAULTS_MUSL_TOOL \ 16310d565efSmrg { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, 16410d565efSmrg #else 16510d565efSmrg #define INCLUDE_DEFAULTS_MUSL_TOOL 16610d565efSmrg #endif 16710d565efSmrg 16810d565efSmrg #ifdef NATIVE_SYSTEM_HEADER_DIR 16910d565efSmrg #define INCLUDE_DEFAULTS_MUSL_NATIVE \ 17010d565efSmrg { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ 17110d565efSmrg { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, 17210d565efSmrg #else 17310d565efSmrg #define INCLUDE_DEFAULTS_MUSL_NATIVE 17410d565efSmrg #endif 17510d565efSmrg 17610d565efSmrg #if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) 17710d565efSmrg # undef INCLUDE_DEFAULTS_MUSL_LOCAL 17810d565efSmrg # define INCLUDE_DEFAULTS_MUSL_LOCAL 17910d565efSmrg # undef INCLUDE_DEFAULTS_MUSL_NATIVE 18010d565efSmrg # define INCLUDE_DEFAULTS_MUSL_NATIVE 18110d565efSmrg #else 18210d565efSmrg # undef INCLUDE_DEFAULTS_MUSL_CROSS 18310d565efSmrg # define INCLUDE_DEFAULTS_MUSL_CROSS 18410d565efSmrg #endif 18510d565efSmrg 18610d565efSmrg #undef INCLUDE_DEFAULTS 18710d565efSmrg #define INCLUDE_DEFAULTS \ 18810d565efSmrg { \ 18910d565efSmrg INCLUDE_DEFAULTS_MUSL_GPP \ 19010d565efSmrg INCLUDE_DEFAULTS_MUSL_LOCAL \ 19110d565efSmrg INCLUDE_DEFAULTS_MUSL_PREFIX \ 19210d565efSmrg INCLUDE_DEFAULTS_MUSL_CROSS \ 19310d565efSmrg INCLUDE_DEFAULTS_MUSL_TOOL \ 19410d565efSmrg INCLUDE_DEFAULTS_MUSL_NATIVE \ 19510d565efSmrg { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ 19610d565efSmrg { 0, 0, 0, 0, 0, 0 } \ 19710d565efSmrg } 19810d565efSmrg #endif 19910d565efSmrg 20010d565efSmrg #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ 20110d565efSmrg /* This is a *uclinux* target. We don't define below macros to normal linux 20210d565efSmrg versions, because doing so would require *uclinux* targets to include 20310d565efSmrg linux.c, linux-protos.h, linux.opt, etc. We could, alternatively, add 20410d565efSmrg these files to *uclinux* targets, but that would only pollute option list 20510d565efSmrg (add -mglibc, etc.) without adding any useful support. */ 20610d565efSmrg 20710d565efSmrg /* Define TARGET_LIBC_HAS_FUNCTION for *uclinux* targets to 20810d565efSmrg no_c99_libc_has_function, because uclibc does not, normally, have 20910d565efSmrg c99 runtime. If, in special cases, uclibc does have c99 runtime, 21010d565efSmrg this should be defined to a new hook. Also please note that for targets 21110d565efSmrg like *-linux-uclibc that similar check will also need to be added to 21210d565efSmrg linux_libc_has_function. */ 21310d565efSmrg # undef TARGET_LIBC_HAS_FUNCTION 21410d565efSmrg # define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function 21510d565efSmrg 21610d565efSmrg #else /* !uClinux, i.e., normal Linux */ 21710d565efSmrg 21810d565efSmrg /* Determine what functions are present at the runtime; 21910d565efSmrg this includes full c99 runtime and sincos. */ 22010d565efSmrg # undef TARGET_LIBC_HAS_FUNCTION 22110d565efSmrg # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function 22210d565efSmrg 22310d565efSmrg #endif 224