1. 31 1月, 2016 1 次提交
    • R
      don't suppress shared libc when linker lacks -Bsymbolic-functions · 65498f28
      Rich Felker 提交于
      previous work overhauling the dynamic linker made it so that linking
      libc with -Bsymbolic-functions was no longer mandatory, but the
      configure logic that forced --disable-shared when ld failed to accept
      the option was left in place.
      
      this commit removes the hard-coded -Bsymbolic-functions from the
      Makefile and changes the configure test to one that simply adds it to
      the auto-detected LDFLAGS on success.
      65498f28
  2. 28 1月, 2016 2 次提交
  3. 26 1月, 2016 1 次提交
    • R
      use same object files for libc.a and libc.so if compiler produces PIC · 1619127c
      Rich Felker 提交于
      now that .lo and .o files differ only by whether -fPIC is passed (and
      no longer at the source level based on the SHARED macro), it's
      possible to use the same object files for both static and shared libc
      when the compiler would produce PIC for the static files anyway. this
      happens if the user has included -fPIC in their CFLAGS or if the
      compiler has been configured to produce PIE by default.
      
      we use the .lo files for both, and still append -fPIC to the CFLAGS,
      rather than using the .o files so that libc.so does not break
      catastrophically if the user later removes -fPIC from CFLAGS in
      config.mak or on the make command line. this also ensures that we get
      full -fPIC in case -fpic, -fPIE, or some other lesser-PIC option was
      passed in CFLAGS.
      1619127c
  4. 21 1月, 2016 1 次提交
  5. 18 1月, 2016 1 次提交
    • P
      support out-of-tree build · 2f853dd6
      Petr Hosek 提交于
      this change adds support for building musl outside of the source
      tree. the implementation is similar to autotools where running
      configure in a different directory creates config.mak in the current
      working directory and symlinks the makefile, which contains the
      logic for creating all necessary directories and resolving paths
      relative to the source directory.
      
      to support both in-tree and out-of-tree builds with implicit make
      rules, all object files are now placed into a separate directory.
      2f853dd6
  6. 08 11月, 2015 1 次提交
  7. 05 11月, 2015 3 次提交
    • R
      have configure check/add --gc-sections linker option · 6a851e3a
      Rich Felker 提交于
      this allowing the linker to drop certain weak definitions that are
      only used as dummies for static linking. they could be eliminated for
      shared library builds using the preprocessor instead, but we are
      trying to transition to using the same object files for shared and
      static libc, so a link-time solution is preferable.
      6a851e3a
    • R
      have configure check/add linker options to reduce size lost to padding · 2efd38e8
      Rich Felker 提交于
      based on patch by Denys Vlasenko. sorting sections and common data
      symbols by alignment acts as an approximation for optimal packing,
      which the linker does not actually support.
      2efd38e8
    • R
      have configure check/add -ffunction-sections and -fdata-sections · 27c1eccf
      Rich Felker 提交于
      based on patch by Denys Vlasenko. the original intent for using these
      options was to enable linking optimizations. these are immediately
      available for static linking applications to libc.a, and will also be
      used for linking libc.so in a subsequent commit.
      
      in addition to the original motives, this change works around a whole
      class of toolchain bugs where the compiler generates relative address
      expressions using a weak symbol and the assembler "optimizes out" the
      relocation which should result by using the weak definition. (see gas
      pr 18561 and gcc pr 66609, 68178, etc. for examples.) by having
      different functions and data objects in their own sections, all
      relative address expressions are cross-section and thus cannot be
      resolved to constants until link time. this allows us to retain
      support for affected compiler/assembler versions without invasive
      and fragile source-level workarounds.
      27c1eccf
  8. 03 11月, 2015 1 次提交
  9. 23 10月, 2015 1 次提交
    • R
      prevent user CFLAGS overrides from exposing executable stack · bc0c4841
      Rich Felker 提交于
      the option to suppress executable stack tagging was placed in CFLAGS,
      which is treated as optional and overridable by the build system. if a
      user replaces CFLAGS after configure has run, it could get lost,
      resulting in a libc.so that's flagged as needing executable stack,
      which would cause the kernel to map the initial stack as executable.
      
      move -Wa,--noexecstack to CFLAGS_C99FSE, the make variable used for
      mandatory compiler options.
      bc0c4841
  10. 16 10月, 2015 1 次提交
  11. 29 9月, 2015 1 次提交
    • R
      eliminate protected-visibility data in libc.so with vis.h preinclude · f3a53f09
      Rich Felker 提交于
      some newer binutils versions print scary warnings about protected data
      because most gcc versions fail to produce the right address
      references/relocations for such data that might be subject to copy
      relocations. originally vis.h explicitly assigned default visibility
      to all public data symbols to avoid this issue, but commit
      b8dda24f removed this treatment for
      stdin/out/err to work around a gcc 3.x bug, and since they don't
      actually need it (because taking their addresses is not valid C).
      
      instead, a check for the gcc 3.x bug is added to the configure check
      for vis.h preinclude support; this feature will simply be disabled
      when using a buggy version of gcc.
      f3a53f09
  12. 22 9月, 2015 2 次提交
  13. 12 9月, 2015 1 次提交
    • R
      add sh fdpic subarch variants · d4c82d05
      Rich Felker 提交于
      with this commit it should be possible to produce a working
      static-linked fdpic libc and application binaries for sh.
      
      the changes in reloc.h are largely unused at this point since dynamic
      linking is not supported, but the CRTJMP macro is used one place
      outside of dynamic linking, in __unmapself.
      d4c82d05
  14. 26 8月, 2015 1 次提交
    • A
      Build process uses script to add CFI directives to x86 asm · 35b3312b
      Alex Dowad 提交于
      Some functions implemented in asm need to use EBP for purposes other
      than acting as a frame pointer. (Notably, it is used for the 6th
      argument to syscalls with 6 arguments.) Without frame pointers, GDB
      can only show backtraces if it gets CFI information from a
      .debug_frame or .eh_frame ELF section.
      
      Rather than littering our asm with ugly .cfi directives, use an awk
      script to insert them in the right places during the build process, so
      GDB can keep track of where the current stack frame is relative to the
      stack pointer. This means GDB can produce beautiful stack traces at
      any given point when single-stepping through asm functions.
      
      Additionally, when registers are saved on the stack and later
      overwritten, emit ..cfi directives so GDB will know where they were
      saved relative to the stack pointer. This way, when you look back up
      the stack from within an asm function, you can still reliably print
      the values of local variables in the caller.
      
      If this awk script were to understand every possible wild and crazy
      contortion that an asm programmer can do with the stack and registers,
      and always emit the exact ..cfi directives needed for GDB to know what
      the register values were in the preceding stack frame, it would
      necessarily be as complex as a full x86 emulator. That way lies
      madness.
      
      Hence, we assume that the stack pointer will _only_ ever be adjusted
      using push/pop or else add/sub with a constant. We do not attempt to
      detect every possible way that a register value could be saved for
      later use, just the simple and common ways.
      
      Thanks to Szabolcs Nagy for suggesting numerous improvements to this
      code.
      35b3312b
  15. 07 7月, 2015 3 次提交
    • S
      add musl-clang, a wrapper for system clang installs · fb58545f
      Shiz 提交于
      musl-clang allows the user to compile musl-powered programs using their
      already existent clang install, without the need of a special cross compiler.
      it achieves this by wrapping around both the system clang install and the
      linker and passing them special flags to re-target musl at runtime.
      it does only affect invocations done through the special musl-clang wrapper
      script, so that the user setup remains fully intact otherwise.
      
      the clang wrapper consists of the compiler frontend wrapper script,
      musl-clang, and the linker wrapper script, ld.musl-clang.
      musl-clang makes sure clang invokes ld.musl-clang to link objects; neither
      script needs to be in PATH for the wrapper to work.
      fb58545f
    • S
      build: fix musl-targeting toolchain test · f8db6f74
      Shiz 提交于
      the old test was broken in that it would never fail on a toolchains built
      without dynamic linking support, leading to the wrapper script possibly being
      installed on compilers that do not support it. in addition, the new test is
      portable across compilers: the old test only worked on GCC.
      
      the new test works by testing whether the toolchain libc defines __GLIBC__:
      most non-musl Linux libc's do define this for compatibility even when they
      are not glibc, so this is a safe bet to check for musl. in addition, the
      compiler runtime would need to have a somewhat glibc-compatible ABI in the
      first place, so any non-glibc compatible libc's compiler runtime might not
      work. it is safer to disable these cases by default and have the user enable
      the wrappers manually there using --enable-wrapper if they certain it works.
      f8db6f74
    • S
      build: overhaul wrapper script system for multiple wrapper support · b3cd7d13
      Shiz 提交于
      this overhauls part of the build system in order to support multiple
      toolchain wrapper scripts, as opposed to solely the musl-gcc wrapper as
      before. it thereby replaces --enable-gcc-wrapper with --enable-wrapper=...,
      which has the options 'auto' (the default, detect whether to use wrappers),
      'all' (build and install all wrappers), 'no' (don't build any) and finally
      the options named after the individual compiler scripts (currently only
      'gcc' is available) to build and install only that wrapper.
      the old --enable-gcc-wrapper is removed from --help, but still available.
      
      it also modifies the wrappers to use the C compiler specified to the build
      system as 'inner' compiler, when applicable. as wrapper detection works by
      probing this compiler, it may not work with any other.
      b3cd7d13
  16. 28 5月, 2015 1 次提交
    • S
      configure: work around compilers that merely warn for unknown options · fc431d3f
      Shiz 提交于
      some compilers (such as clang) accept unknown options without error,
      but then print warnings on each invocation, cluttering the build
      output and burying meaningful warnings. this patch makes configure's
      tryflag and tryldflag functions use additional options to turn the
      unknown-option warnings into errors, if available, but only at check
      time. these options are not output in config.mak to avoid the risk of
      spurious build breakage; if they work, they will have already done
      their job at configure time.
      fc431d3f
  17. 23 4月, 2015 1 次提交
  18. 22 4月, 2015 2 次提交
    • R
      make configure check for visibility preinclude compatible with pcc · 428462a4
      Rich Felker 提交于
      pcc does not search for -include relative to the working directory
      unless -I. is used. rather than adding -I., which could be problematic
      if there's extra junk in the top-level directory, switch back to the
      old method (reverting commit 60ed988f)
      of using -include vis.h and relying on -I./src/internal being present
      on the command line (which the Makefile guarantees). to fix the
      breakage that was present in trycppif checks with the old method,
      $CFLAGS_AUTO is removed from the command line passed to trycppif; this
      is valid since $CFLAGS_AUTO should not contain options that alter
      compiler semantics or ABI, only optimizations, warnings, etc.
      428462a4
    • A
      configure: check for -march and -mtune passed via CC · a6274a19
      Andre McCurdy 提交于
      Some build environments pass -march and -mtune as part of CC, therefore
      update configure to check both CC and CFLAGS before making the decision
      to fall back to generic -march and -mtune options for x86.
      Signed-off-by: NAndre McCurdy <armccurdy@gmail.com>
      a6274a19
  19. 21 4月, 2015 1 次提交
    • R
      fix regression in configure script with new visibility option · 60ed988f
      Rich Felker 提交于
      commit de2b67f8 introduced a
      regression by adding a -include option to CFLAGS_AUTO which did not
      work without additional -I options. this broke subsequent trycppif
      tests and caused x86_64 to be misdetected as x32, among other issues.
      simply using the full relative pathname to vis.h rather than -I is the
      cleanest way to fix the problem.
      60ed988f
  20. 20 4月, 2015 1 次提交
    • R
      add optional global visibility override · de2b67f8
      Rich Felker 提交于
      this is implemented via the build system and does not affect source
      files. the idea is to use protected or hidden visibility to prevent
      the compiler from pessimizing function calls within a shared (or
      position-independent static) libc in the form of overhead setting up
      for a call through the PLT. the ld-time symbol binding via the
      -Bsymbolic-functions option already optimized out the PLT itself, but
      not the code in the caller needed to support a call through the PLT.
      on some archs this overhead can be substantial; on others it's
      trivial.
      de2b67f8
  21. 14 4月, 2015 1 次提交
    • R
      allow libc itself to be built with stack protector enabled · 1ef849c6
      Rich Felker 提交于
      this was already essentially possible as a result of the previous
      commits changing the dynamic linker/thread pointer bootstrap process.
      this commit mainly adds build system infrastructure:
      
      configure no longer attempts to disable stack protector. instead it
      simply determines how so the makefile can disable stack protector for
      a few translation units used during early startup.
      
      stack protector is also disabled for memcpy and memset since compilers
      (incorrectly) generate calls to them on some archs to implement
      struct initialization and assignment, and such calls may creep into
      early initialization.
      
      no explicit attempt to enable stack protector is made by configure at
      this time; any stack protector option supported by the compiler can be
      passed to configure in CFLAGS, and if the compiler uses stack
      protector by default, this default is respected.
      1ef849c6
  22. 12 3月, 2015 1 次提交
    • S
      add aarch64 port · 01ef3dd9
      Szabolcs Nagy 提交于
      This adds complete aarch64 target support including bigendian subarch.
      
      Some of the long double math functions are known to be broken otherwise
      interfaces should be fully functional, but at this point consider this
      port experimental.
      
      Initial work on this port was done by Sireesh Tripurari and Kevin Bortis.
      01ef3dd9
  23. 31 1月, 2015 1 次提交
  24. 19 7月, 2014 1 次提交
    • S
      add or1k (OpenRISC 1000) architecture port · 200d1547
      Stefan Kristiansson 提交于
      With the exception of a fenv implementation, the port is fully featured.
      The port has been tested in or1ksim, the golden reference functional
      simulator for OpenRISC 1000.
      It passes all libc-test tests (except the math tests that
      requires a fenv implementation).
      
      The port assumes an or1k implementation that has support for
      atomic instructions (l.lwa/l.swa).
      
      Although it passes all the libc-test tests, the port is still
      in an experimental state, and has yet experienced very little
      'real-world' use.
      200d1547
  25. 17 7月, 2014 1 次提交
    • R
      work around constant folding bug 61144 in gcc 4.9.0 and 4.9.1 · a6adb2bc
      Rich Felker 提交于
      previously we detected this bug in configure and issued advice for a
      workaround, but this turned out not to work. since then gcc 4.9.0 has
      appeared in several distributions, and now 4.9.1 has been released
      without a fix despite this being a wrong code generation bug which is
      supposed to be a release-blocker, per gcc policy.
      
      since the scope of the bug seems to affect only data objects (rather
      than functions) whose definitions are overridable, and there are only
      a very small number of these in musl, I am just changing them from
      const to volatile for the time being. simply removing the const would
      be sufficient to make gcc 4.9.1 work (the non-const case was
      inadvertently fixed as part of another change in gcc), and this would
      also be sufficient with 4.9.0 if we forced -O0 on the affected files
      or on the whole build. however it's cleaner to just remove all the
      broken compiler detection and use volatile, which will ensure that
      they are never constant-folded. the quality of a non-broken compiler's
      output should not be affected except for the fact that these objects
      are no longer const and thus possibly add a few bytes to data/bss.
      
      this change can be reconsidered and possibly reverted at some point in
      the future when the broken gcc versions are no longer relevant.
      a6adb2bc
  26. 21 6月, 2014 1 次提交
  27. 11 6月, 2014 1 次提交
    • R
      fail configure on --enable-shared if -Bsymbolic-functions doesn't work · d79b2778
      Rich Felker 提交于
      previously, a warning was issued in this case no matter what, even if
      --disable-shared was used. now, the default for --enable-shared is
      changed from "yes" to "auto", and the warning is issued by default,
      but becomes an error if --enable-shared is used, and the test is
      suppressed completely if --disable-shared is used.
      d79b2778
  28. 21 5月, 2014 1 次提交
  29. 19 5月, 2014 1 次提交
    • R
      add configure check for broken gcc 4.9.0 and possibly other versions · 9ca4dae5
      Rich Felker 提交于
      this is gcc bug #61144. the broken compiler is detected, but the user
      must manually work around it. this is partly to avoid complex logic
      for adding workaround CFLAGS and attempting to recheck with them, and
      partly for the sake of letting the user know the compiler is broken
      (since the workaround will result in less-efficient code production).
      
      some refactoring was also needed to move the check for gcc outside of
      the check for whether to build the compiler wrapper.
      9ca4dae5
  30. 13 5月, 2014 1 次提交
    • R
      add configure check for working compiler · 8945667f
      Rich Felker 提交于
      without this, broken choices of CC/CPPFLAGS/CFLAGS don't show up until
      late in the configure process where they are confusingly reported as a
      different failure such as incorrect long double type.
      8945667f
  31. 28 4月, 2014 1 次提交
    • B
      fix superh nofpu check on old gcc versions · 23d64182
      Bobby Bingham 提交于
      As far as gcc3 knows, sh4 is the only processor version that can have an
      FPU, so it indicates the FPU's presence by defining __SH4__.  This is not
      defined if there is no FPU, even if the processor really is an SH4.
      
      Starting with gcc4, there is support for the sh2a processor, which has an
      FPU but is not an SH4.  gcc4 therefore additionally defines __SH_FPU_ANY__
      when there is an FPU, but still doesn't define __SH4__ for an FPU-less sh4.
      
      Therefore, to support all gcc versions, we must look at both preprocessor
      symbols.
      23d64182
  32. 20 3月, 2014 1 次提交
  33. 18 3月, 2014 1 次提交
    • R
      make configure accept alternate gcc tuples for x32 · f162c064
      Rich Felker 提交于
      the previous pattern required "x32" to be used as the second field of
      the gcc tuple, which is usually reserved for vendor use and not
      appropriate as an ABI specifier. with this change, putting "x32" at
      the end of the tuple, the way ABI specifiers are normally done, is
      also permitted.
      f162c064