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

Multiple -fdebug-prefix-map options are not considered correctly when deciding to hash the current directory #163

Closed
mikecrowe opened this issue Mar 15, 2017 · 5 comments
Labels
bug Does not work as intended/documented
Milestone

Comments

@mikecrowe
Copy link

The OpenEmbedded build system passes multiple -fdebug-prefix-map= options to the compiler in order to map the source directory and sysroots separately.

Unfortunately, ccache appears to only store the last of these arguments. The previous ones are overwritten (and the local copies leak):

		if (str_startswith(argv[i], "-fdebug-prefix-map=")) {
			debug_prefix_map = x_strdup(argv[i] + 19);
			args_add(stripped_args, argv[i]);
			continue;
		}

The arguments still make it through to the compiler, but only the last is considered when deciding which directory to put into the hash when conf->hash_dir is enabled. This means that the current directory always ends up in the hash even when it has no effect on the generated files.

@afbjorklund
Copy link
Contributor

Yeah, this needs to be converted into an array of some-sorts.

philb pushed a commit to openembedded/openembedded-core that referenced this issue Mar 16, 2017
As of ccache-3.3, ccache tries to ensure that the paths in the debug
information are always correct. It does this by including the current
directory in the hash if debug output is enabled. It includes support for
detecting remapping via a single -fdebug-prefix-map argument uses the
remapped directory in the hash instead.

The DEBUG_PREFIX_MAP in bitbake.conf remaps the source directory, target
sysroot and native sysroot separately which results in multiple
-fdebug-prefix-map arguments. Although ccache passes all these arguments
through to the compiler, it only enables the special behaviour described
above if the last one matches the current directory. (See
ccache/ccache#163 )

Even if ccache did correctly honour each of the remapping arguments, the
hashes would still be different every time ${PV} or ${PR} change because
the default DEBUG_PREFIX_MAP contains maps to paths including them.

So it seems that for ccache to be of any use with this configuration,
CCACHE_NOHASHDIR needs to be set.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
philb pushed a commit to openembedded/openembedded-core that referenced this issue Mar 17, 2017
As of ccache-3.3, ccache tries to ensure that the paths in the debug
information are always correct. It does this by including the current
directory in the hash if debug output is enabled. It includes support for
detecting remapping via a single -fdebug-prefix-map argument uses the
remapped directory in the hash instead.

The DEBUG_PREFIX_MAP in bitbake.conf remaps the source directory, target
sysroot and native sysroot separately which results in multiple
-fdebug-prefix-map arguments. Although ccache passes all these arguments
through to the compiler, it only enables the special behaviour described
above if the last one matches the current directory. (See
ccache/ccache#163 )

Even if ccache did correctly honour each of the remapping arguments, the
hashes would still be different every time ${PV} or ${PR} change because
the default DEBUG_PREFIX_MAP contains maps to paths including them.

So it seems that for ccache to be of any use with this configuration,
CCACHE_NOHASHDIR needs to be set.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
philb pushed a commit to openembedded/openembedded-core that referenced this issue Mar 17, 2017
As of ccache-3.3, ccache tries to ensure that the paths in the debug
information are always correct. It does this by including the current
directory in the hash if debug output is enabled. It includes support for
detecting remapping via a single -fdebug-prefix-map argument uses the
remapped directory in the hash instead.

The DEBUG_PREFIX_MAP in bitbake.conf remaps the source directory, target
sysroot and native sysroot separately which results in multiple
-fdebug-prefix-map arguments. Although ccache passes all these arguments
through to the compiler, it only enables the special behaviour described
above if the last one matches the current directory. (See
ccache/ccache#163 )

Even if ccache did correctly honour each of the remapping arguments, the
hashes would still be different every time ${PV} or ${PR} change because
the default DEBUG_PREFIX_MAP contains maps to paths including them.

So it seems that for ccache to be of any use with this configuration,
CCACHE_NOHASHDIR needs to be set.

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
afbjorklund added a commit to afbjorklund/ccache that referenced this issue Mar 17, 2017
Previously only the last one was actually being applied to the hash.
Note that the compiler will actually only *use* one of all the paths.

Closes ccache#163.
@jrosdahl jrosdahl added the bug Does not work as intended/documented label Mar 25, 2017
@jrosdahl jrosdahl added this to the 3.3.5 milestone Mar 25, 2017
@mikecrowe
Copy link
Author

The fix seems to work for me. Changing my OpenEmbedded build directory no longer invalidates the cached files. (Unfortunately, changing the package version does still invalidate the cached files because the debug-prefix-map destination contains the version number. :( )

@afbjorklund
Copy link
Contributor

But if you are interested in encoding the package version in your debuginfo like that, then I suppose that is a feature (or else you would change the remapping, I suppose ?)

@mikecrowe
Copy link
Author

But if you are interested in encoding the package version in your debuginfo like that, then I suppose that is a feature (or else you would change the remapping, I suppose ?)

Yes, but that's an upstream OpenEmbedded design decision (which appeared in ecb56a6ae0c870af680da03db9d39703b525fc98 for anyone following along.) I would need to override it locally or persuade them to change it.

@afbjorklund
Copy link
Contributor

I suppose there is always hash_dir = false otherwise, if you don't care about the subdir.

daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
As of ccache-3.3, ccache tries to ensure that the paths in the debug
information are always correct. It does this by including the current
directory in the hash if debug output is enabled. It includes support for
detecting remapping via a single -fdebug-prefix-map argument uses the
remapped directory in the hash instead.

The DEBUG_PREFIX_MAP in bitbake.conf remaps the source directory, target
sysroot and native sysroot separately which results in multiple
-fdebug-prefix-map arguments. Although ccache passes all these arguments
through to the compiler, it only enables the special behaviour described
above if the last one matches the current directory. (See
ccache/ccache#163 )

Even if ccache did correctly honour each of the remapping arguments, the
hashes would still be different every time ${PV} or ${PR} change because
the default DEBUG_PREFIX_MAP contains maps to paths including them.

So it seems that for ccache to be of any use with this configuration,
CCACHE_NOHASHDIR needs to be set.

(From OE-Core rev: fb7a5cdcff19bb44a25a51e20de0440c1ebcc057)

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
daregit pushed a commit to daregit/yocto-combined that referenced this issue May 22, 2024
As of ccache-3.3, ccache tries to ensure that the paths in the debug
information are always correct. It does this by including the current
directory in the hash if debug output is enabled. It includes support for
detecting remapping via a single -fdebug-prefix-map argument uses the
remapped directory in the hash instead.

The DEBUG_PREFIX_MAP in bitbake.conf remaps the source directory, target
sysroot and native sysroot separately which results in multiple
-fdebug-prefix-map arguments. Although ccache passes all these arguments
through to the compiler, it only enables the special behaviour described
above if the last one matches the current directory. (See
ccache/ccache#163 )

Even if ccache did correctly honour each of the remapping arguments, the
hashes would still be different every time ${PV} or ${PR} change because
the default DEBUG_PREFIX_MAP contains maps to paths including them.

So it seems that for ccache to be of any use with this configuration,
CCACHE_NOHASHDIR needs to be set.

(From OE-Core rev: fb7a5cdcff19bb44a25a51e20de0440c1ebcc057)

Signed-off-by: Mike Crowe <mac@mcrowe.com>
Helped-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Does not work as intended/documented
Projects
None yet
Development

No branches or pull requests

3 participants