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

ccache isn't supported with --cross_file option #1392

Closed
fabio-porcedda opened this issue Feb 16, 2017 · 3 comments · Fixed by #1396
Closed

ccache isn't supported with --cross_file option #1392

fabio-porcedda opened this issue Feb 16, 2017 · 3 comments · Fixed by #1396

Comments

@fabio-porcedda
Copy link
Contributor

To be able to use ccache with a cross compiler I've added the 'ccache' string in the cross_file:

[binaries]
c = ['ccache', '/usr/local/bin/mips-linux-gcc']

Meson fails using the above cross_file:

The Meson build system
Version: 0.38.1
Source dir: /ssd/lte/app-2/tcommon/src/oma-dm/kt_lib
Build dir: /ssd/lte/app-2/tcommon/src/oma-dm/kt_lib/build
Build type: cross build
Project name: kt_lib
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 286, in run
app.generate()
File "/usr/lib/python3.5/site-packages/mesonbuild/mesonmain.py", line 160, in generate
intr = interpreter.Interpreter(b, g)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1198, in init
self.parse_project()
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 111, in parse_project
self.evaluate_codeblock(self.ast, end=1)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock
raise e
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock
self.evaluate_statement(cur)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement
return self.function_call(cur)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call
return self.funcs[func_name](node, self.flatten(posargs), kwargs)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreterbase.py", line 55, in wrapped
return f(self, node, args, kwargs)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1611, in func_project
self.add_languages(args[1:], True)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1727, in add_languages
(comp, cross_comp) = self.detect_compilers(lang, need_cross_compiler)
File "/usr/lib/python3.5/site-packages/mesonbuild/interpreter.py", line 1652, in detect_compilers
cross_comp = self.environment.detect_c_compiler(True)
File "/usr/lib/python3.5/site-packages/mesonbuild/environment.py", line 371, in detect_c_compiler
basename = os.path.basename(compiler).lower()
File "/usr/lib64/python3.5/posixpath.py", line 139, in basename
i = p.rfind(sep) + 1
AttributeError: 'list' object has no attribute 'rfind'

Any idea how to fix that?

Thanks
Fabio Porcedda

@fabio-porcedda
Copy link
Contributor Author

IMHO I've a working solution for this problem, tomorrow i will make a pull request.

@nirbheek
Copy link
Member

nirbheek commented Feb 16, 2017

The basic issue, as I said on the PR, is that we expect a string there, and we don't actually check that it's a string, and throw a traceback if it's any other object. The solution would be to check if it's a string, and use it as a string, and if it's a list, use it as a list.

If it's anything else, report a proper error instead of spewing traceback.

@jpakkane
Copy link
Member

The function you probably want to use is mesonlib.stringlistify.

fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 17, 2017
Add the possibility to enable the ccache using the cross_file.
To use ccache add the 'ccache' string before the compiler string, e.g.:

cross_file.txt:

[binaries]
c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes mesonbuild#1392.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 17, 2017
- Hanlde correctly a multi command string in evironment variable, e.g.:
  CC="ccache gcc" meson
- Handle correctly a list for the cross-file option, e.g:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes mesonbuild#1392.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 17, 2017
- Hanlde correctly a multi command string in evironment variable, e.g.:
  CC="ccache gcc" meson
- Handle correctly a list for the cross-file option, e.g:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes mesonbuild#1392.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 17, 2017
- Hanlde correctly a multi command string in evironment variable, e.g.:
  CC="ccache gcc" meson
- Handle correctly a list for the cross-file option, e.g:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes mesonbuild#1392.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 17, 2017
- Hanlde correctly a multi command string in evironment variable, e.g.:
  CC="ccache gcc" meson
- Handle correctly a list for the cross-file option, e.g:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes mesonbuild#1392.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 17, 2017
- Hanlde correctly a multi command string in evironment variable, e.g.:
  CC="ccache gcc" meson
- Handle correctly a list for the cross-file option, e.g:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

This commit fixes mesonbuild#1392.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 20, 2017
The pull mesonbuild#1406 reverted some changes of the pull mesonbuild#1396 so extra
commands doesn't work anymore, e.g.:

cross_file.txt:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

or

  CC="ccache gcc" meson

This commit fix issue mesonbuild#1392 again.
fabio-porcedda added a commit to fabio-porcedda/meson that referenced this issue Feb 20, 2017
The pull mesonbuild#1406 reverted some changes of the pull mesonbuild#1396 so extra
commands doesn't work anymore, e.g.:

cross_file.txt:
  [binaries]
  c = ['ccache', '/usr/local/bin/mips-linuc-gcc']

or

  CC="ccache gcc" meson

This commit fix issue mesonbuild#1392 again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants