Re: [gentoo-dev] Gentoo Installer (text-based)

2011-02-10 Thread Konstantin Tokarev


10.02.2011, 12:56, Antoni Grzymala awa...@chopin.edu.pl:
 Fabian Groffen dixit (2011-02-10, 10:39):

  On 10-02-2011 07:54:16 +0100, Fabio Erculiani wrote:
  The only way to avoid epic failures is to keep the whole thing simple,
  without trying to fit everybody. An installer that would cover a
  standard install, newbie-oriented scenario would be definitely good.
  Experienced people won't use it anyway, so why bothering trying to
  cover their needs, it would be a straight way to fail again.
  Just FYI:
  Interestingly, it were the power/experienced users that requested a
  simple installer, because they got tired of copypaste-ing the same
  commands from the manual over and over again.

 Actually power users install Gentoo from memory...

dd if=/dev/brain of=/dev/hda1

:)

-- 
Regards,
Konstantin



Re: [gentoo-dev] Re: Move x86/amd64 CPU extensions USE flags to a new USE_EXPAND variable

2010-12-15 Thread Konstantin Tokarev

 And rather than trusting gcc
 -march=native to do the work for you, you would probably be better off
 checking `grep ^flags /proc/cpuinfo' anyway. :)


Gentoo runs not only on Linux (remember about Gentoo Prefix), and this feature 
is 
system-dependend

-- 
Regards,
Konstantin



Re: [gentoo-dev] Re: Move x86/amd64 CPU extensions USE flags to a new USE_EXPAND variable

2010-12-13 Thread Konstantin Tokarev


13.12.2010, 18:53, Francesco R viv...@gmail.com:
 2010/12/13 Ryan Hill dirtye...@gentoo.org
 On Sun, 12 Dec 2010 09:01:13 -0400
 Sergio D. Rodríguez Inclan srinc...@gmail.com wrote:

   El 12/12/2010 02:46 a.m., Ryan Hill escribió:
  I think the fewer sources of magic USE flags the better.  Maybe we could
  document how to figure out what instruction sets a processor supports in 
  the
  handbook instead.

 A good manual would be greatly appreciated :)

 I wrote a guide a couple weeks ago that might be a good starting point.

 http://en.gentoo-wiki.com/wiki/Hardware_CFLAGS

 if I read correctly the article on the wiki it does circa what the script 
 reported below does.
 would be possible to adopt something similar for automatic C*FLAGS selection 
 if someone step in willing to take the pain to mantain it.

 #!/usr/bin/python
 # Copyright 2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # Author: Francesco Riosa
 # extrapolated from http://en.gentoo-wiki.com/wiki/Hardware_CFLAGS, errors 
 are mine

 # kate: encoding utf-8; eol unix
 # kate: indent-width 4; mixedindent off; replace-tabs on;
 # kate: remove-trailing-space on; space-indent on

 # echo int main() { return 0; } | gcc -march=native -v -E - 21 | grep 
 march
 # echo int main() { return 0; } | gcc -march=core2 -v -Q -x c - 21

 
 example output:
 ./hw-cflags.py
 extrapolating flags for gcc-4.4.5
   useful flags: -march=core2 -msse4.1 --param l1-cache-size=32 --param 
 l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=generic
   redundant:    -mcx16 -msahf

 extrapolating flags for gcc-4.5.1
   useful flags: -march=core2 -msse4.1 --param l1-cache-size=32 --param 
 l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=core2
   redundant:    -mcx16 -msahf
 

 import os
 import time
 import fnmatch
 from subprocess import Popen, PIPE

 GCC_PATH = '/usr/bin/'
 GCC_LIST = fnmatch.filter(os.listdir(GCC_PATH), 'gcc-[0-9].*')
 GCC_LIST.sort()

 def extract_flags(gcccmd, header):
     # get output from gcc
     buf = ''
     devnul = open('/dev/null', 'w')
     p = Popen(gcccmd, stdin=PIPE, stdout=devnul, stderr=PIPE)
     p.stdin.write(int main() { return 0; })
     p.stdin.close()
     while p.poll() is None:
         t = p.stderr.read()
         buf = buf%s % t
         time.sleep(0.01)
     p.stderr.close()
     devnul.close()

     # parse it
     flags = []
     add = False
     for line in buf.split('\n'):
         if line.startswith(header):
             add = True
             flags += line.strip().split(' ')
             continue
         if add:
             if line.startswith(' '):
                 flags += line.strip().split(' ')
             else:
                 break

     # extract flags we are interested in
     t = []
     march = ''
     mtune = '-mtune=generic'
     for i in xrange(len(flags)):
         if flags[i].startswith('-m'):
             if flags[i].startswith('-mtune'):
                 mtune = flags[i]
             elif flags[i].startswith('-march'):
                 march = flags[i]
             else:
                 t.append(flags[i])
         elif flags[i] == '--param':
             t.append(%s %s % (flags[i], flags[i+1]))
     flags = t

     return march, mtune, flags

 for gcc in GCC_LIST:

     print extrapolating flags for %s % gcc

     gcccmd = [ GCC_PATH + gcc, '-march=native', '-v', '-E', '-', ]
     header='COLLECT_GCC_OPTIONS'
     march, mtune, flags_native = extract_flags(gcccmd, header)

     gcccmd = [ GCC_PATH + gcc, march, '-v', '-Q', '-x', 'c', '-', ]
     header='options enabled:'
     t, t, flags_enabled = extract_flags(gcccmd, header)

     redundant_flags = []
     useful_flags = []

     for x in flags_native:
         if x in flags_enabled:
             redundant_flags.append(x)
         else:
             useful_flags.append(x)

     if gcc  gcc-4.5.0:
         mtune = '-mtune=generic'

     print   useful flags: %s %s %s  % (march,  .join(useful_flags), mtune)
     print   redundant:    %s %  .join(redundant_flags)
     print

Note that for some architectures (e.g, PowerPC) you need to add -mcpu case
(-mcpu has the same meaning as -march on x86)


-- 
Regards,
Konstantin