﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
1190	Mac bundle builds fail when compiling C code	Tristan Croll	Conrad Huang	"Clang complains and crashes if you ask it to compile a C file with -std=c++11. While `bundle_builder.py` currently contains the following:

{{{
        if sys.platform == ""darwin"":
            libraries = self.libraries
            # Unfortunately, clang on macOS (for now) exits
            # when receiving a -std=c++11 option when compiling
            # a C (not C++) source file, which is why this value
            # is named ""cpp_flags"" not ""compile_flags""
            cpp_flags = [""-std=c++11"", ""-stdlib=libc++""]

}}}

... it isn't actually used as such, and `cpp_flags` just gets attached to every compilation. The following amendment to `_CLibrary.compile()` is one way to tackle it (here I'm killing two birds with one stone by also parallelising it over all available cores):

{{{
        from concurrent.futures import ThreadPoolExecutor
        import os
        results = []
        with ThreadPoolExecutor(max_workers=os.cpu_count()-1) as executor:
            for f in self.source_files:
                l = compiler.detect_language(f)
                if l == 'c':
                    preargs = []
                elif l == 'c++':
                    preargs = cpp_flags
                else:
                    raise RuntimeError('Unsupported language for {}'.format(f))
                results.append(executor.submit(compiler.compile, [f], extra_preargs=preargs, macros=macros, debug=debug))
            #Ensure all have finished before continuing
            for r in results:
                r.result()
        #compiler.compile(self.source_files, extra_preargs=cpp_flags, macros=macros, debug=debug)
}}}

Not quite sure how to tackle the same problem with _CModule, though - that's a somewhat different beast."	defect	closed	moderate		Tool Shed		fixed						all	ChimeraX
