<commit_before>module HomebrewEnvExtension
  # -w: keep signal to noise high
  SAFE_CFLAGS_FLAGS = "-w -pipe"

  def setup_build_environment
    # Clear CDPATH to avoid make issues that depend on changing directories
    delete('CDPATH')
    delete('CPPFLAGS')
    delete('LDFLAGS')

    self['MAKEFLAGS'] = "-j#{Hardware.processor_count}"

    unless HOMEBREW_PREFIX.to_s == '/usr/local'
      # /usr/local is already an -isystem and -L directory so we skip it
      self['CPPFLAGS'] = "-isystem #{HOMEBREW_PREFIX}/include"
      self['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib"
      # CMake ignores the variables above
      self['CMAKE_PREFIX_PATH'] = "#{HOMEBREW_PREFIX}"
    end

    # llvm allows -O4 however it often fails to link and is very slow
    cflags = ['-O3']

    # If these aren't set, many formulae fail to build
    self['CC'] = '/usr/bin/cc'
    self['CXX'] = '/usr/bin/c++'

    if MACOS_VERSION >= 10.6
      if self.use_clang?
        self['CC']  = "#{MacOS.xcode_prefix}/usr/bin/clang"
        self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++"
      elsif self.use_llvm? and MacOS.xcode_version < '4.1'
        # With Xcode 4 cc is llvm
        self['CC']  = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
        self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
      elsif self.use_gcc? and MacOS.xcode_version < '4'
        # With Xcode4 cc, c++, gcc and g++ are actually symlinks to llvm-gcc
        self['CC']  = "#{MacOS.xcode_prefix}/usr/bin/gcc-4.2"
        self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/g++-4.2"
      end
    end

    # In rare cases this may break your builds, as the tool for some reason wants
    # to use a specific linker. However doing this in general causes formula to
    # build more successfully because we are changing CC and many build systems
    # don't react properly to that.
    self['LD'] = self['CC']

    # Optimise all the way to eleven, references:
    # http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
    # http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
    # http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
    # We don't set, eg. -msse3 because the march flag does that for us:
    # http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/i386-and-x86_002d64-Options.html
    if MACOS_VERSION >= 10.6
      case Hardware.intel_family
      when :nehalem, :penryn, :core2
        # the 64 bit compiler adds -mfpmath=sse for us
        cflags << "-march=core2"
      when :core
        cflags<<"-march=prescott"<<"-mfpmath=sse"
      end
      # gcc doesn't auto add msse4 or above (based on march flag) yet
      case Hardware.intel_family
      when :nehalem
        cflags << "-msse4" # means msse4.2 and msse4.1
      when :penryn
        cflags << "-msse4.1"
      end
    else<commit_msg>Use -march=native when we don't otherwise know<commit_after>module HomebrewEnvExtension
  # -w: keep signal to noise high
  SAFE_CFLAGS_FLAGS = "-w -pipe"

  def setup_build_environment
    # Clear CDPATH to avoid make issues that depend on changing directories
    delete('CDPATH')
    delete('CPPFLAGS')
    delete('LDFLAGS')

    self['MAKEFLAGS'] = "-j#{Hardware.processor_count}"

    unless HOMEBREW_PREFIX.to_s == '/usr/local'
      # /usr/local is already an -isystem and -L directory so we skip it
      self['CPPFLAGS'] = "-isystem #{HOMEBREW_PREFIX}/include"
      self['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib"
      # CMake ignores the variables above
      self['CMAKE_PREFIX_PATH'] = "#{HOMEBREW_PREFIX}"
    end

    # llvm allows -O4 however it often fails to link and is very slow
    cflags = ['-O3']

    # If these aren't set, many formulae fail to build
    self['CC'] = '/usr/bin/cc'
    self['CXX'] = '/usr/bin/c++'

    if MACOS_VERSION >= 10.6
      if self.use_clang?
        self['CC']  = "#{MacOS.xcode_prefix}/usr/bin/clang"
        self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/clang++"
      elsif self.use_llvm? and MacOS.xcode_version < '4.1'
        # With Xcode 4 cc is llvm
        self['CC']  = "#{MacOS.xcode_prefix}/usr/bin/llvm-gcc"
        self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/llvm-g++"
      elsif self.use_gcc? and MacOS.xcode_version < '4'
        # With Xcode4 cc, c++, gcc and g++ are actually symlinks to llvm-gcc
        self['CC']  = "#{MacOS.xcode_prefix}/usr/bin/gcc-4.2"
        self['CXX'] = "#{MacOS.xcode_prefix}/usr/bin/g++-4.2"
      end
    end

    # In rare cases this may break your builds, as the tool for some reason wants
    # to use a specific linker. However doing this in general causes formula to
    # build more successfully because we are changing CC and many build systems
    # don't react properly to that.
    self['LD'] = self['CC']

    # Optimise all the way to eleven, references:
    # http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
    # http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
    # http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/i386-and-x86_002d64-Options.html
    # We don't set, eg. -msse3 because the march flag does that for us:
    # http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/i386-and-x86_002d64-Options.html
    if MACOS_VERSION >= 10.6
      case Hardware.intel_family
      when :nehalem, :penryn, :core2
        # the 64 bit compiler adds -mfpmath=sse for us
        cflags << "-march=core2"
      when :core
        cflags<<"-march=prescott"<<"-mfpmath=sse"
      else
        # note that this didn't work on older versions of Xcode's gcc
        # and maybe still doesn't. But it's at least not worse than nothing.
        cflags << "-march=native"
      end
      # gcc doesn't auto add msse4 or above (based on march flag) yet
      case Hardware.intel_family
      when :nehalem
        cflags << "-msse4" # means msse4.2 and msse4.1
      when :penryn
        cflags << "-msse4.1"
      end
    else
{'fraction_non_alphanumeric': 0.13103211403056844, 'fraction_numerical': 0.021981796324918427, 'mean_word_length': 2.6814159292035398, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4202591', 'n_tokens_mistral': 2128, 'n_tokens_neox': 1993, 'n_words': 539}