<commit_before>from __future__ import absolute_import
from __future__ import print_function


import os
import sys
import tempfile
import hashlib

from shutil import copyfile
from .filetype import FileType
from .popenwrapper import Popen
from .arglistfilter import ArgumentListFilter

from .logconfig import logConfig

# Internal logger
_logger = logConfig(__name__)

def wcompile(mode):
    """ The workhorse, called from wllvm and wllvm++.
    """

    rc = 1

    legible_argstring = ' '.join(list(sys.argv)[1:])

    # for diffing with gclang
    _logger.info('Entering CC [%s]', legible_argstring)

    try:
        cmd = list(sys.argv)
        cmd = cmd[1:]

        builder = getBuilder(cmd, mode)

        af = builder.getBitcodeArglistFilter()

        rc = buildObject(builder)

        # phase one compile failed. no point continuing
        if rc != 0:
            _logger.error('Failed to compile using given arguments: [%s]', legible_argstring)
            return rc

        # no need to generate bitcode (e.g. configure only, assembly, ....)<commit_msg>Exit if wllvm is invoked from ccache<commit_after>from __future__ import absolute_import
from __future__ import print_function


import os
import sys
import tempfile
import hashlib
import subprocess

from shutil import copyfile
from .filetype import FileType
from .popenwrapper import Popen
from .arglistfilter import ArgumentListFilter

from .logconfig import logConfig

# Internal logger
_logger = logConfig(__name__)

def wcompile(mode):
    """ The workhorse, called from wllvm and wllvm++.
    """

    # Make sure we are not invoked from ccache
    parentCmd = subprocess.check_output(
            ['ps', '--no-header', '-o', 'comm', '-p', str(os.getppid())], text=True)
    if parentCmd.strip() == 'ccache':
        # The following error message may be invisible in terminal because ccache captures stderr
        _logger.error('Should not be invoked from ccache')
        # When ccache detects an error during preprocessing,
        # it will fall back to running the real compiler (wllvm)
        sys.exit(-1)

    rc = 1

    legible_argstring = ' '.join(list(sys.argv)[1:])

    # for diffing with gclang
    _logger.info('Entering CC [%s]', legible_argstring)

    try:
        cmd = list(sys.argv)
        cmd = cmd[1:]

        builder = getBuilder(cmd, mode)

        af = builder.getBitcodeArglistFilter()

        rc = buildObject(builder)

        # phase one compile failed. no point continuing
        if rc != 0:
            _logger.error('Failed to compile using given arguments: [%s]', legible_argstring)
            return rc

        # no need to generate bitcode (e.g. configure only, assembly, ....)
{'fraction_non_alphanumeric': 0.0901669758812616, 'fraction_numerical': 0.003339517625231911, 'mean_word_length': 2.9530791788856305, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4182966', 'n_tokens_mistral': 796, 'n_tokens_neox': 763, 'n_words': 269}