diff --git a/src/python/pants/backend/native/tasks/c_compile.py b/src/python/pants/backend/native/tasks/c_compile.py index f21f25de5171..8e2ad6f816ee 100644 --- a/src/python/pants/backend/native/tasks/c_compile.py +++ b/src/python/pants/backend/native/tasks/c_compile.py @@ -59,12 +59,10 @@ def compile(self, compile_request): self.context.log.debug("no sources in request {}, skipping".format(compile_request)) return - # TODO: add -fPIC, but only to object files used for shared libs (how do we determine that?) -- - # alternatively, only allow using native code to build shared libs. c_compiler = compile_request.compiler err_flags = ['-Werror'] if compile_request.fatal_warnings else [] - # We are executing in the results_dir, so get absolute paths for everything. - # TODO: -fPIC all the time??? + # We are going to execute in `output_dir`, so get absolute paths for everything. + # TODO: If we need to produce static libs, don't add -fPIC! (could use Variants -- see #5788). cmd = [c_compiler.exe_filename] + err_flags + ['-c', '-fPIC'] + [ '-I{}'.format(os.path.abspath(inc_dir)) for inc_dir in compile_request.include_dirs ] + [os.path.abspath(src) for src in sources] diff --git a/src/python/pants/backend/native/tasks/cpp_compile.py b/src/python/pants/backend/native/tasks/cpp_compile.py index aa1d2941cdce..212ff79f8e4d 100644 --- a/src/python/pants/backend/native/tasks/cpp_compile.py +++ b/src/python/pants/backend/native/tasks/cpp_compile.py @@ -59,8 +59,8 @@ def compile(self, compile_request): cpp_compiler = compile_request.compiler err_flags = ['-Werror'] if compile_request.fatal_warnings else [] - # We are executing in the results_dir, so get absolute paths for everything. - # TODO: -fPIC all the time??? + # We are going to execute in `output_dir`, so get absolute paths for everything. + # TODO: If we need to produce static libs, don't add -fPIC! (could use Variants -- see #5788). cmd = [cpp_compiler.exe_filename] + err_flags + ['-c', '-fPIC'] + [ '-I{}'.format(os.path.abspath(inc_dir)) for inc_dir in compile_request.include_dirs ] + [os.path.abspath(src) for src in sources]