Closed cmaurini closed 1 year ago
Could you post the error message?
On a broader note, we should perhaps throw an exception if string contains spaces...
Yes I think that a clear exception would be perfect. It is a bad idea to put spaces in names, but it it may happen. That's the second time I take 20 mins to figure out the issue in student codes. Here the error message.
libffcx_forms_04c39657d35cd0902d6ef26b99320c5d1fd53c04.c:1116:46: error: expected ';' at end of declaration
static ufcx_function_space functionspace_with space =
^
;
libffcx_forms_04c39657d35cd0902d6ef26b99320c5d1fd53c04.c:1126:29: error: expected ';' after return statement
return &functionspace_with space;
^
;
2 errors generated.
Traceback (most recent call last):
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/opt/homebrew/bin/clang' failed with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
self._build_extensions_serial()
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
self.build_extension(ext)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
_build_ext.build_extension(self, ext)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
objects = self.compiler.compile(
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/opt/homebrew/bin/clang' failed with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/maurini/Documents/codes/FFT-FEM/test.py", line 19, in <module>
fem.assemble_scalar(fem.form(3 * u_2 * dx))
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 166, in form
return _create_form(form)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 161, in _create_form
return _form(form)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 135, in _form
ufcx_form, module, code = jit.ffcx_jit(mesh.comm, form,
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/dolfinx/jit.py", line 56, in mpi_jit
return local_jit(*args, **kwargs)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/dolfinx/jit.py", line 204, in ffcx_jit
r = ffcx.codegeneration.jit.compile_forms([ufl_object], parameters=p_ffcx, **p_jit)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 168, in compile_forms
impl = _compile_objects(decl, forms, form_names, module_name, p, cache_dir,
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 252, in _compile_objects
ffibuilder.compile(tmpdir=cache_dir, verbose=True, debug=cffi_debug)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/cffi/api.py", line 725, in compile
return recompile(self, module_name, source, tmpdir=tmpdir,
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/cffi/recompiler.py", line 1564, in recompile
outputfilename = ffiplatform.compile('.', ext,
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/Users/maurini/opt/anaconda3/envs/fenicsx-0.5.1/lib/python3.10/site-packages/cffi/ffiplatform.py", line 58, in _build
raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command '/opt/homebrew/bin/clang' failed with exit code 1```
Could you post the error message?
On a broader note, we should perhaps throw an exception if string contains spaces...
I think it is a general mistake that we use the function names in the generated code.
As we renumber the coefficients in the signature, we should just use this number, i.e. f_0
, f_1
etc
yet, it is useful when one try to look at the generated code
See https://github.com/FEniCS/ffcx/blob/main/ffcx/codegeneration/form.py#L111, which means function names must be a valid C identifier.
For forms, it is not really required we put function names into C object names, since we fetch them anyway with a string, but this is in place for expressions. Anyway, I think, as the code suggests, ufcx_function_space
generation should be rewritten. I just made a simple check, https://github.com/FEniCS/ffcx/pull/539
@michalhabera does https://github.com/FEniCS/ffcx/pull/539 resolve this issue?
Yes, in a sense that an exception saying "Function name {name} must be a valid object identifier." will be thrown from ffcx.
Function name strings including spaces leads to a ffcx error and a strange error message. See the MWE below.
I have this issue with version 0.5.1