DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD Package System (pkgsrc)

NetBSD Package System (pkgsrc) Installation and upgrading of packages on NetBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 27th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 68
Unhappy pkgsrc optimization flags ignored

Hello all,

I gain the impression my optimization flags are ignored. This is from my /etc/mk.conf

Code:
CPUFLAGS+=           -march=native DDDDDD1
COPTS+=              -g -O2 -pipe CCCCCC1
I would expect the compilation to fail due to the Ds and Cs. It does not. I also tried setting bogus CFLAGS.

A grep for these flags does not show up in the build directory, either.

Code:
# grep -R DDDDDD1 /var/tmp/pkgsrc/graphics/xli/work/
# grep -R CCCCCC1 /var/tmp/pkgsrc/graphics/xli/work/
I tried graphics/xli as pkgsrc's xli Makefile is quite simple making it unlikely to overwrite mk.conf variables.
Reply With Quote
  #2   (View Single Post)  
Old 27th July 2020
thirdm thirdm is offline
Spam Deminer
 
Join Date: May 2009
Posts: 243
Default

I'm using the cpuflags package:

Code:
$ make show-var VARNAME=COPTS    
-pipe 
$ make show-var VARNAME=CPUFLAGS

$ make show-var VARNAME=CPU_FLAGS
-mfpmath=sse -msse3 -march=native
Maybe you should be setting CPU_FLAGS instead of CPUFLAGS. But that doesn't explain how your COPTS isn't getting through, unless xmi happens not to use it.
Reply With Quote
  #3   (View Single Post)  
Old 27th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 68
Default

About CFLAGS, vs COPTS, CPUFLAGS, CPU_FLAGS:

My original /etc/mk.conf file from many years ago used CFLAGS only. This document still recommends it https://www.netbsd.org/docs/pkgsrc/configuring.html

I then found COPTS and CPUFLAGS in man mk.conf. It's not clear to me if that is only used for building the kernel and userland or also for pkgsrc. Sensucht94 also uses CPUFLAGS in his fancy /etc/mk.conf file http://daemonforums.org/showthread.php?t=11326


My ultimate goal is to rebuild pkgsrc with debug symbols so I can analyze core files.

What I have now in /etc/mk.conf

Code:
CPUFLAGS+=              -march=native
COPTS+=                 -g -O2 -pipe
CFLAGS+=                -g
This results in

Code:
/usr/pkgsrc/graphics/xli# make show-var VARNAME=COPTS
-g -O2 -pipe
/usr/pkgsrc/graphics/xli# make show-var VARNAME=CFLAGS
-O2 -g -D_FORTIFY_SOURCE=2
/usr/pkgsrc/graphics/xli# make show-var VARNAME=CPUFLAGS
-march=native

/usr/pkgsrc/graphics/xli# make clean; make

/usr/pkgsrc/graphics/xli# gdb /var/tmp/pkgsrc/graphics/xli/work/xli-2005-02-27/xli
...
Reading symbols from /var/tmp/pkgsrc/graphics/xli/work/xli-2005-02-27/xli...
(No debugging symbols found in /var/tmp/pkgsrc/graphics/xli/work/xli-2005-02-27/xli)
Reply With Quote
  #4   (View Single Post)  
Old 27th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 68
Default

Quote:
COPTS isn't getting through, unless xmi happens not to use it.
Yesterday, I tried several packages with the same result.

I just tried a package based on ./configure and there my flags are passed through and debugging symbols are found.

Code:
Reading symbols from /var/tmp/pkgsrc/devel/yasm/work/yasm-1.3.0/yasm...
Disappointing that I can not build debugging symbols for all packages.
Reply With Quote
  #5   (View Single Post)  
Old 28th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 68
Default

I experimented with CFLAGS, COPTS, CPUFLAGS, CPU_FLAGS adding -g.

I only find debugging symbols in the binary when -g is passed via CFLAGS.

Sensucht94 and thirdm, I recommend you double-checking your optimization flags. You may find I'm right and only CFLAGS (and CXXFLAGS for g++) are passed the compiler.
Reply With Quote
  #6   (View Single Post)  
Old 28th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 68
Default

What seems to work for all tested packages is creating this wrapper

Code:
$ cat /opt/bin/gcc 
/usr/bin/gcc -g $*
and adding /opt/bin to the front of the PATH for pkgsrc builds.

Same for g++.

Not elegant, but hey.

I hesitate putting my fancy CFLAGS into this wrapper so that also xli and other non-configure based packages benefit from custom CFLAGS, because some package Makefiles do magic transformations of CLFAGS.
Reply With Quote
  #7   (View Single Post)  
Old 1st August 2020
thirdm thirdm is offline
Spam Deminer
 
Join Date: May 2009
Posts: 243
Default

For myself I don't want to add any custom wrappers around gcc. pkgsrc does more than enough wrapping itself for my taste.

I'm new to pkgsrc and NetBSD, but my guess is that this is one of those things that we cannot expect pkgsrc itself to solve. Maybe xli (and others you've tried?) is one of those packages made to ignore custom flags and needs to be patched. See section 10.15 of the pkgsrc guide.
Reply With Quote
Reply

Tags
cflags, pkgsrc

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to OpenBSD, could use some help on some issues and possible optimization options therue OpenBSD General 27 17th November 2019 02:11 PM
flags in vi's man page attilio OpenBSD Packages and Ports 4 13th December 2016 12:34 PM
openbsd server optimization barti OpenBSD General 18 30th July 2012 02:52 PM
Which is the significance about pkgsrc-2009Q2 and pkgsrc-2009Q3? aleunix NetBSD Package System (pkgsrc) 3 16th December 2009 07:19 AM
FreeBSD Kernel Optimization komodo FreeBSD General 5 22nd June 2009 07:15 AM


All times are GMT. The time now is 12:14 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick