Skip to contentSkip to conversation

icecc: base fix for cross and native builds

PATCH Applied Roman I Khimov 4 participants 10 messages Feb 12, 2009 – Feb 14, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 icecc: base fix for cross and native builds

Hello all.

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

So, here is a patch that fixes some basic things, like:
1) ICECC_ENV_EXEC variable expansion. Currently you can only use absolute path here, something like "${TOP}/create-icecc-env.sh" won't work.
2) PATH is set wrong for cross-compiler, the problem is that ${ICECC_PATH} is expanded at script-producing stage, so as a result you have

export PATH=/usr/bin/icecc$PATH

in script, which is just plain wrong.
3) Cross-compiler tarball created is not working, at least with 4.3.3 GCC version when 'create-icecc-env.sh' script tries to find cc1 and cc1plus it gets nothing meaningful, like:

   $ ./tmp/cross/i686/i686-linux/bin/gcc -print-prog-name=cc1
   cc1
   $ ./tmp/cross/i686/i686-linux/bin/gcc -print-prog-name=cc1plus
   cc1plus

Compare that to

   $ ./tmp/cross/i686/bin/i686-linux-gcc -print-prog-name=cc1
   /path-to-oe-top/tmp/cross/i686/libexec/gcc/i686-linux/4.3.3/cc1
   $ ./tmp/cross/i686/bin/i686-linux-gcc -print-prog-name=cc1plus
   /path-to-oe-top/tmp/cross/i686/libexec/gcc/i686-linux/4.3.3/cc1plus

This patch fixes this problems and one can use icecc with it, albeit there are some problems left, 'icecc-create-env' is not working as create-icecc-env.sh provider and there is a problem with parallel task execution (as in BB_NUMBER_THREADS) if several tasks get ready to run, try to find icecc tarball, not find that, and then every task tries to create the tarball which leads to all sorts of corruption in resulting tarball.

classes/icecc.bbclass +12 -8
@@ -83,13 +83,15 @@ def create_cross_env(bb,d):
 
     #check if user has specified a specific icecc-create-env script
     #if not use the OE provided one
-    cr_env_script = bb.data.getVar('ICECC_ENV_EXEC',  d) or  bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
+    cr_env_script = bb.data.expand('${ICECC_ENV_EXEC}',  d)
+    if cr_env_script == "${ICECC_ENV_EXEC}":
+        cr_env_script = bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
     #call the modified create-env script
     result=os.popen("%s %s %s %s %s %s" %(cr_env_script,
            "--silent",
-           os.path.join(ice_dir,target_sys,'bin','gcc'),
-           os.path.join(ice_dir,target_sys,'bin','g++'),
-           os.path.join(ice_dir,target_sys,'bin','as'),
+           os.path.join(ice_dir, 'bin', "%s-gcc" % target_sys),
+           os.path.join(ice_dir, 'bin', "%s-g++" % target_sys),
+           os.path.join(ice_dir, 'bin', "%s-as" % target_sys),
            os.path.join(ice_dir,"ice",cross_name) ) )
     return tar_file
 
@@ -121,7 +123,9 @@ def create_native_env(bb,d):
 
     #check if user has specified a specific icecc-create-env script
     #if not use the OE provided one
-    cr_env_script = bb.data.getVar('ICECC_ENV_EXEC',  d) or  bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
+    cr_env_script = bb.data.expand('${ICECC_ENV_EXEC}',  d)
+    if cr_env_script == "${ICECC_ENV_EXEC}":
+        cr_env_script = bb.data.expand('${STAGING_DIR}', d)+"/ice/icecc-create-env"
     result=os.popen("%s %s %s %s %s %s" %(cr_env_script,
            "--silent",
            os.popen("%s gcc" % "which").read()[:-1],
@@ -290,9 +294,9 @@ def check_for_kernel(bb,d):     
 
 
 set_icecc_env() {
-    ICECC_PATH=${@icc_path(bb,d)}
-    if test x${ICECC_PATH} != x; then
-	export PATH=${ICECC_PATH}$PATH
+    ICE_PATH=${@icc_path(bb,d)}
+    if test x${ICE_PATH} != x; then
+	export PATH=${ICE_PATH}$PATH
 	export CCACHE_PATH=$PATH
         #check if we are building a kernel and select gcc-cross-kernel
         if [ "${@check_for_kernel(bb,d)}" = "yes" ]; then
Signature · 4 lines
                            Roman
 http://roman.khimov.ru
mailto: [email protected]
gpg --keyserver hkp://subkeys.pgp.net --recv-keys 0xE5E055C3
#1 lore raw
Quoted 8 lines · Roman I Khimov

Hello all.

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

So, here is a patch that fixes some basic things, like:
1) ICECC_ENV_EXEC variable expansion. Currently you can only use absolute

    path here, something like "${TOP}/create-icecc-env.sh" won't work.

${TOP} is dangerous to use, IIRC openssl uses it in its buildsystem, so people that have TOP set (hi Raster & Steve) see all kind of weird failures.

regards,

Koen

#2 lore raw

Koen Kooi:

Quoted 6 lines · Roman I Khimov
Quoted 5 lines

Hello all.

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

Quoted 8 lines
Quoted 4 lines

So, here is a patch that fixes some basic things, like:
1) ICECC_ENV_EXEC variable expansion. Currently you can only use absolute path here, something like "${TOP}/create-icecc-env.sh" won't work.

${TOP} is dangerous to use, IIRC openssl uses it in its buildsystem, so people that have TOP set (hi Raster & Steve) see all kind of weird failures.

I'm not using "${TOP}" anywhere in production, it's just an example, still it's the case that ${ANY_VARIABLE} in ICECC_ENV_EXEC will breake icecc.

Signature · 4 lines
                            Roman
 http://roman.khimov.ru
mailto: [email protected]
gpg --keyserver hkp://subkeys.pgp.net --recv-keys 0xE5E055C3
#3 lore raw
In reply to Roman I Khimov

Hello,

Quoted 5 lines · Roman I Khimov

Hello all.

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

Excellent!

It's probably a little-used class, but if we get it to work more robustly, we can make more noise about it.

I will try to do some tests here over the next few weeks with your patch, time permitting.

Regards,

Signature · 1 line
Leon
#4 lore raw
Quoted 8 lines · Leon Woestenberg

Hello,

Quoted 5 lines · Roman I Khimov

Hello all.

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

Quoted 7 lines

Excellent!

It's probably a little-used class, but if we get it to work more robustly, we can make more noise about it.

I will try to do some tests here over the next few weeks with your patch, time permitting.

Once icecc works we should have a chat with the suse buildservice people. PARALLEL_MAKE = "-j256", here we come :)

regards,

Koen

#5 lore raw

Koen Kooi:

Quoted 7 lines · Leon Woestenberg
Quoted 6 lines · Roman I Khimov
Quoted 2 lines

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

Excellent!

Quoted 8 lines
Quoted 5 lines

It's probably a little-used class, but if we get it to work more robustly, we can make more noise about it.

I will try to do some tests here over the next few weeks with your patch, time permitting.

Once icecc works we should have a chat with the suse buildservice people. PARALLEL_MAKE = "-j256", here we come :)

I'm running it with "-j14" there and combined with bitbake parallel task execution it just rocks, the only slowdowns are blacklisted packages like gcc and glibc.

So, if anyone cares enough to commit? ;)

The most severe problem left after this patch is parallel tarball creation, which I'm not sure how to fix better. An obvious solution is some kind of file lock but from what I see, the best way to do it is via pathutils module which is not standard.

Another approach could be just reducing the race window, fixing create-icecc-env.sh to write to temporary file and then move it to its place. Maybe that would be enough.

Another approach could be some kind of IPC locks between running threads, but I don't know enough on how bitbake runs its parallel tasks and whether it's possible or not.

Another approach could be moving tarball creation to packages and then use standard dependency features of bitbake, making native things depend on native tarball and cross on cross. Not sure how to do it in details.

Signature · 4 lines
                            Roman
 http://roman.khimov.ru
mailto: [email protected]
gpg --keyserver hkp://subkeys.pgp.net --recv-keys 0xE5E055C3
#6 lore raw
Quoted 12 lines · Roman I Khimov

Koen Kooi:

Quoted 11 lines · Leon Woestenberg
Quoted 10 lines · Roman I Khimov
Quoted 2 lines

There are severe problems with icecc builds currently in OE. Cross-compiler tarball created wrong, PATH set incorrectly, etc.

Excellent!

It's probably a little-used class, but if we get it to work more robustly, we can make more noise about it.

I will try to do some tests here over the next few weeks with your patch, time permitting.

Quoted 8 lines
Quoted 2 lines

Once icecc works we should have a chat with the suse buildservice people. PARALLEL_MAKE = "-j256", here we come :)

I'm running it with "-j14" there and combined with bitbake parallel task execution it just rocks, the only slowdowns are blacklisted packages like gcc and glibc.

So, if anyone cares enough to commit? ;)

AIUI Leon wants to give it a spin first, but you have my +1.

regards,

Koen

#7 lore raw

Hello,

Quoted 5 lines · Koen Kooi
Quoted 1 line · Roman I Khimov

So, if anyone cares enough to commit? ;)

AIUI Leon wants to give it a spin first, but you have my +1.

Hmm, if it is broken currently, and now fixed and tested by you, +1 for committing it right away.
I can do this tomorrow - but beware...

I'm not getting around to fulfill my own wannado's, didn't get around to test icecc today.

Well, I just finished installing 'bob' the build server, might as well deploy icecc on it.

Regards,

Signature · 1 line
Leon
#9 lore raw
In reply to Roman I Khimov

Roman I Khimov:

Quoted 3 lines

Another approach could be just reducing the race window, fixing create-icecc-env.sh to write to temporary file and then move it to its place. Maybe that would be enough.

BTW, this kind of kludge seems to be working, at least for two runs on dual-core and quad-core machines.

create-icecc-env.sh +3 -1
@@ -181,12 +181,14 @@ else
  fi
 
 fi
+TEMPFILE=`tempfile`
 cd $tempdir
-tar -czhf "$mydir/$archive_name".tar.gz $target_files || {
+tar -czhf $TEMPFILE $target_files || {
  if test -z "$silent"; then
   echo "Couldn't create archive"
  fi
   exit 3
 }
 cd ..
+mv $TEMPFILE "$mydir/$archive_name".tar.gz
 rm -rf $tempdir