Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make_cffi.py incorrectly finds compiler #103

Closed
Arfrever opened this issue May 8, 2020 · 2 comments
Closed

make_cffi.py incorrectly finds compiler #103

Arfrever opened this issue May 8, 2020 · 2 comments
Labels

Comments

@Arfrever
Copy link

Arfrever commented May 8, 2020

make_cffi.py incorrectly finds compiler:

  • It does not call customize_compiler() function, which would make code respect user-set CC environmental variable.
  • It uses compiler.executables["compiler"], which is only a class-default non-customized value. compiler.compiler should be called instead.

Compare:

$ CC="x86_64-pc-linux-gnu-gcc" python -c 'import distutils.ccompiler; compiler = distutils.ccompiler.new_compiler(); print(compiler.executables["compiler"])'
['cc']
$ CC="x86_64-pc-linux-gnu-gcc" python -c 'import distutils.ccompiler; compiler = distutils.ccompiler.new_compiler(); distutils.sysconfig.customize_compiler(compiler); print(compiler.compiler)'
['x86_64-pc-linux-gnu-gcc']

Patch: make_cffi.patch.txt

@indygreg indygreg added the bug label Jun 13, 2020
@indygreg
Copy link
Owner

Good find! I'll commit this patch shortly. Thank you!

@Arfrever
Copy link
Author

Arfrever commented Jun 18, 2020

You have not applied the last part of patch, so CC variable is still ignored.
This is still needed:

--- a/make_cffi.py
+++ b/make_cffi.py
@@ -84,7 +84,7 @@
 # Distutils doesn't set compiler.preprocessor, so invoke the preprocessor
 # manually.
 if compiler.compiler_type == "unix":
-    args = list(compiler.executables["compiler"])
+    args = compiler.compiler
     args.extend(
         ["-E", "-DZSTD_STATIC_LINKING_ONLY", "-DZDICT_STATIC_LINKING_ONLY",]
     )

compiler.compiler, compiler.compiler_so, compiler.linker_exe, compiler.linker_so etc. attributes are already lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants