Nuitka icon indicating copy to clipboard operation
Nuitka copied to clipboard

AttributeError: 'ListAction' object has no attribute 'replace':

Open dicotom opened this issue 9 months ago • 1 comments

using CC=C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\x64\bin\clang.exe

AttributeError: 'ListAction' object has no attribute 'replace': File "C:\PYTHON~1\Lib\SITE-P~1\nuitka\build\BACKEN~1.SCO", line 1061: makeGccUseLinkerFile( File "c:\Python312\Lib\site-packages\nuitka\build\SconsHacks.py", line 184: env["LINKCOM"] = env["LINKCOM"].replace( FATAL: Failed unexpectedly in Scons C backend compilation. Nuitka:WARNING: Complex topic! More information can be found at https://nuitka.net/info/scons-backend-failure.html Nuitka-Reports: Compilation crash report written to file 'nuitka-crash-report.xml'.

in windows 10 nuitka version 2.6.7 python 3.12.6 clang 19.1.1 installed as part of visual studio 2022

with gcc works fine.

replaced original function def makeGccUseLinkerFile(env, source_files): with:

def makeGccUseLinkerFile(env, source_files): tmp_linker_filename = os.path.join(env.source_dir, "@link_input.txt")

if isinstance(env["SHLINKCOM"], str):
    env["SHLINKCOM"] = env["SHLINKCOM"].replace(
        "$SOURCES", "@%s" % env.get("ESCAPE", lambda x: x)(tmp_linker_filename)
    )

if isinstance(env["LINKCOM"], str):  # Ensure LINKCOM is a string
    env["LINKCOM"] = env["LINKCOM"].replace(
        "$SOURCES", "@%s" % env.get("ESCAPE", lambda x: x)(tmp_linker_filename)
    )

with openTextFile(tmp_linker_filename, "w") as tmpfile:
    for filename in source_files:
        filename = ".".join(filename.split(".")[:-1]) + (
            ".os" if env.module_mode and os.name != "nt" else ".o"
        )

        if os.name == "nt":
            filename = filename.replace(os.path.sep, "/")

        tmpfile.write('"%s"\n' % filename)

    tmpfile.write(env.subst("$SOURCES"))

fine with function above, but a lot more errors: attached file errorsNUITKA.txt

dicotom avatar Mar 06 '25 13:03 dicotom

errorsNUITKA.txt

dicotom avatar Mar 06 '25 13:03 dicotom

That's now how it's supposed to work:

CC='C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\x64\bin\clang.exe'

However, I agree ought to work. It is however not detected as a clangcl.exe which may be all there is to it.

kayhayen avatar Oct 10 '25 18:10 kayhayen

Ah no, only clangcl.exe would be supposed to work. It's not a proper clang and then is mishandled entirely. I call this user error.

kayhayen avatar Oct 10 '25 18:10 kayhayen