You are not logged in.

#1 2018-07-25 12:51:41

Shino
Member
From: Germany
Registered: 2015-02-01
Posts: 66

Can I disable WARNING: Package contains reference to $srcdir

Hello,

I've written a program using glib. I created a PKGBUILD for it and built a package. I get following warning:

==> WARNING: Package contains reference to $srcdir

Somewhere in my binary there's a path that points to the build directory.

After analyzing this problem a bit, I found out that in some macro expansion of glib, the __FILE__ macro is used for creating warnings.
This is the cause why the full path of the source code is compiled into the binary.

Is there some way to either disable the warning or tell GCC not to return the full path when using __FILE__?


Thank you

Offline

#2 2018-07-25 13:33:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

That doesn't seem to add up.  Are you using the __FILE__ macro in your code?  Are there compile-time warnings?  If so, what are they?  What package is this?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-07-25 15:46:27

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Can I disable WARNING: Package contains reference to $srcdir

Trilby, makepkg itself will emit warnings during the "Checking for packaging issues..." stage. It's defined in /usr/share/makepkg/lint_package/build_references.sh

Shino, there is no option to disable this and Arch Linux has been working on https://reproducible-builds.org/, use of the __FILE__ macro breaks this and chances are there's a better way to achieve the goal here than to use __FILE__. But if you're okay with not being reproducible, simply ignore these warnings, since warnings are not errors due to them being warnings instead.

...

Well, I guess you could define a function in your PKGBUILD:

warn_build_references() {
    : # I like __FILE__ and don't consider build references to be a problem
}

Last edited by eschwartz (2018-07-25 15:49:54)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2018-07-25 16:43:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

Eschwartz wrote:

Trilby, makepkg itself will emit warnings during the "Checking for packaging issues..." stage. It's defined in /usr/share/makepkg/lint_package/build_references.sh

Yes, but it will only do so under certain conditions.  I've built packages that use glib and never encountered this warning.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-07-25 17:01:47

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Can I disable WARNING: Package contains reference to $srcdir

I got confused by your question about compile-time warnings, not sure why using __FILE__ would imply those. smile

From the sound of it, glib provides some special macro that you can use to print runtime warnings, but said macro automatically uses __FILE__ for it...

g_warning maybe. glib code is ugly. sad

Last edited by eschwartz (2018-07-25 17:04:24)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#6 2018-07-25 17:06:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

I was asking because the original problem/question seemed about as clear as mud to me.  I had no idea what was going on.  Something in the source code is triggering this issue.  I thought perhaps explicitly-enabled compile-time warnings could have triggered the inclusion of __FILE__ somewhere in the resulting binary.  If so, disabling that compiler flag/option should suffice.  But again - I was just grasping at straws as there didn't seem to be nearly enough information here to go on.

Trying to disable makepkg's warning or preventing gcc from using a full path seem like very ugly bandaids on a symptom when the underlying problem should be fixed.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2018-07-25 18:57:32

Shino
Member
From: Germany
Registered: 2015-02-01
Posts: 66

Re: Can I disable WARNING: Package contains reference to $srcdir

Trilby wrote:

I was asking because the original problem/question seemed about as clear as mud to me.  I had no idea what was going on.  Something in the source code is triggering this issue.  I thought perhaps explicitly-enabled compile-time warnings could have triggered the inclusion of __FILE__ somewhere in the resulting binary.  If so, disabling that compiler flag/option should suffice.  But again - I was just grasping at straws as there didn't seem to be nearly enough information here to go on.

Trying to disable makepkg's warning or preventing gcc from using a full path seem like very ugly bandaids on a symptom when the underlying problem should be fixed.

The underlying problem is that makpkg tries to be clever. It searches all files in yout package whether they contain any string that contains the $srcdir path.

Because the GLIB macro

G_OBJECT_WARN_INVALID_PROPERTY_ID()

uses __FILE__, the compiler puts in a reference to the compile directory. This is noticed by makepkg. I cannot change that macro, except for removing it.

I think I will just ignore the warning.

Last edited by Shino (2018-07-25 19:00:11)

Offline

#8 2018-07-25 19:05:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

But this is what I'm missing: are you explicitly using that macro?  This is not a problem on other packages that use glib, so why is it happening with your package?  We/I could replicate your situation and answer all of these questions if you'd say what package this was (as previously requested) or just paste a PKGBUILD.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2018-07-25 19:20:59

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Can I disable WARNING: Package contains reference to $srcdir

The macro is probably used by glib internally.

__FILE__ seems to reflect the paths passed to the compiler (I did a quick test with gcc). Most makefiles/build scripts use relative paths and build() starts in $srcdir; that might explain why this is usually not a problem. Are you explicitly using absolute paths or using some other unconventional build method?

Offline

#10 2018-07-26 17:25:30

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Can I disable WARNING: Package contains reference to $srcdir

The generated variety of build scripts do not always use relative paths, e.g. CMake.

ninja and autotools though, do use relative paths.

...

This can be fun, makepkg already had a bug due to that: https://git.archlinux.org/pacman.git/co … 1cfa57fe34


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#11 2018-07-26 18:10:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

I'm still wondering why we should speculate on which build systems or which conditions, etc, might result in symptoms resembling these.  If we could just see the PKGBUILD, we could know for sure.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#12 2018-07-27 07:39:12

Shino
Member
From: Germany
Registered: 2015-02-01
Posts: 66

Re: Can I disable WARNING: Package contains reference to $srcdir

Trilby wrote:

I'm still wondering why we should speculate on which build systems or which conditions, etc, might result in symptoms resembling these.  If we could just see the PKGBUILD, we could know for sure.

I don't understand why you are speculating. I've stated pretty clear, that the usage of the __FILE__ macro triggers this warning during the packaging process. I just wanted to know, whether there is a way to disable this warning in this package because I cannot change the behaviour of __FILE__.

I don't know why you want to see a PKGBUILD? It won't work for you because it references a network internal repository. And as I  wrote in my original question, seems nobody read it, it is a custom application.
But here you go. It's basically a standard PKGBUILD file copy pasted from the wiki page.

pkgname=ppnvx-conv
pkgver=20180725.001
pkgrel=1
pkgdesc="Conversion tool for PPnVX"
arch=('i686' 'x86_64')
licence=('GPLv2')
depends=('glib2' 'gtk3' 'cairo')
makedepends=('cmake' 'git')
privides=('ppnvx-conv')
source=("${pkgname}-git"::"git+https://git.vpn/shino/ppnvx-conv")
sha1sums=('SKIP')

pkgver () {
	_date=`date +"%Y%m%d"`
	cd "${srcdir}/${pkgname}-git"
	echo "$_date.$(git rev-list --count master).$(git rev-parse --short master)"
}

build () {
	cd "$srcdir/$pkgname-git"
	cmake .
	make
}

package () {
	cd "$srcdir/$pkgname-git"
	make DESTDIR="${pkgdir}" install 
	install -D -m664 "$srcdir/$pkgname-git/misc/ppnvx-conv.desktop" \
			 "$pkgdir/usr/share/applications/ppnvx-conv.desktop"
	install -D -m664 "$srcdir/$pkgname-git/icon/ppnvx-conv.svg" \
			 "$pkgdir/usr/share/icons/hicolor/scalable/apps/ppnvx-conv.svg"
}

Last edited by Shino (2018-07-27 07:51:44)

Offline

#13 2018-07-27 13:02:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

Sigh ...

I wanted to see relevant materials so we could replicate what you are seeing.  Often this would be the PKGBUILD, in this case it is not - but we only know that now that you have provided that.  You did not mention in your OP that the source code was not available.  But you did mention you wrote it - so you could make it available.  Is there something proprietary or secret about it?

Unless there are legal hurdles preventing it, providing a means for others to replicate your steps and your problem is a basic expectation of any troubleshooting thread.  Anytime getting those materials is an uphill battle for no apparent reason, I am inclined to suspect (and have been previously proven correct in every case) that the one asking for help is intentionally hiding something directly relevant to the problem.

In any case, I give up.  If you are content to ignore the warning as you imply, then just mark this thread as SOLVED.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#14 2021-09-14 09:59:26

followait
Banned
Registered: 2019-11-01
Posts: 58

Re: Can I disable WARNING: Package contains reference to $srcdir

I have encountered the same problem.
The warning from makepkg is ok, but too simple, it would be mixed with a same warning by a real problem.

3 years passed, no solution yet?

BTW, I think makepkg should not check so deeply into the binary. __FILE__ is just a string essentially.

Last edited by followait (2021-09-14 10:10:43)

Offline

#15 2021-09-14 10:47:06

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,784
Website

Re: Can I disable WARNING: Package contains reference to $srcdir

Not sure why you felt the need to necrobump a three year old topic when it contains the same answers as your own -- ignore the warnings or fix the code. You have been warned multiple times about following our community rules, and you still seem to think they don't apply to you, even after previous tempbans.

https://wiki.archlinux.org/title/Genera … bumping%22

Closing. Banning.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

Board footer

Powered by FluxBB