LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-07-2014, 02:49 PM   #1
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Anyway to tell if a compile was succesful in the past?


Hi folks,

I wonder if its possible to tell if a compile already has been done?

Assumming you have a shell script where you get various sources and build them. While getting the script to behave nice you always start it over and over again and it compiles over and over again. Is gcc able to shorten this process? Or would I have to query for any specific file to tell that the program is already compiled?
 
Old 01-07-2014, 04:33 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Do you mean 'man ccache' or something else?
 
Old 01-08-2014, 01:09 AM   #3
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by zhjim View Post
While getting the script to behave nice you always start it over and over again and it compiles over and over again. Is gcc able to shorten this process?
You have heard of "make" haven't you? If you have a properly written makefile, source files that have already been compiled successfully won't be re-compiled again. But stuff that failed to compile will.

I can't tell from your description above if you are trying to debug a problem compiling your source code, or debug a problem in your makefile dependencies. If you've got a buggy makefile, you could have all kinds of failures - things could re-compile needlessly, things that still need to be compiled might be missed, etc. You have to set up your dependencies correctly in the makefile.
 
Old 01-08-2014, 01:47 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748

Original Poster
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
ccache could help to some point, thanks unspawn.

@haertig its not problem with the make file or the build not finishing. Let me explain a bit better what I'm hunting after.
Code:
#/bin/bash
# download some c sources we need for our project
wget some.sourcecode/coolproject
wget some.even/coolerproject
wget this.project/is/the/bomb

# untar the projects
...

# cd into each dir and compile
cd coolproject
make && make install

# create some very cool stuff using the compiled sources
do some_crazy stuff

# we are done now
echo "your überproject is done sire"
Take this pseudo pseudo code. We get some stuff and compile it. Everything compiles fine. Just at the point of "do some_crazy stuff" we refine and sharpen our shell script some more. So everytime we run this script the compilation would be done too. And thats the point where I need info. The first run is just compile everything. But on the second run I would not need to compile cause it already has been compiled. But as far as I've seen the compile starts over and over again on every call to the script. No real problem just time consuming.
 
Old 01-08-2014, 12:10 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Hmm, my choice would be to not have all that stuff in one script. Downloading source is one thing, compiling it is another, and executing the results is a third - I don't put all those seperate operations into one script myself. But you obviously know what you're doing and have a reason for it.

make will not normally re-compile stuff that doesn't need re-compiling (given that you have a well written makefile). However, you are re-downloading and re-un'tarring your source each time, so make sees that as newly updated source and thus recompiles it.

Even if you can control source file timestamps so that make doesn't re-compile, you will still be wasting a lot of time re-downloading and re-un'tarring.

What I would do is remove the downloading, un'tarring and make'ing from your script. Use the script only to execute the result. And then put all the other operations into a seperate script that is invoked via cron at some "who cares?" time in the middle of the night. You could improve that cron-initiated script to only re-download when a new version of the source is available, or you could just leave it inefficiently doing things over and over again in the middle of the night (when nobody really cares anyway).
 
Old 01-09-2014, 04:08 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748

Original Poster
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by haertig View Post
Hmm, my choice would be to not have all that stuff in one script. Downloading source is one thing, compiling it is another, and executing the results is a third - I don't put all those seperate operations into one script myself. But you obviously know what you're doing and have a reason for it.
Seems I can hide me incapacity quite well That would be my approach too but right now I'm using another ones script so I first need to understand it completly before I go rip it apart. Also not sure if its worth it.


Quote:
Originally Posted by haertig View Post
make will not normally re-compile stuff that doesn't need re-compiling (given that you have a well written makefile). However, you are re-downloading and re-un'tarring your source each time, so make sees that as newly updated source and thus recompiles it.
The actual script uses git so its not redownloading it all. I was just over simplifying my pseudo pseudo script. The well written makefile got me started. There is a make clean at the start of every build. Also okay if run for the first time, it just destroyes everything on further compiles. IIRC. Guess I takle that after breaking the script into pieces.
Quote:
Originally Posted by haertig View Post
Even if you can control source file timestamps so that make doesn't re-compile, you will still be wasting a lot of time re-downloading and re-un'tarring.

What I would do is remove the downloading, un'tarring and make'ing from your script. Use the script only to execute the result. And then put all the other operations into a seperate script that is invoked via cron at some "who cares?" time in the middle of the night. You could improve that cron-initiated script to only re-download when a new version of the source is available, or you could just leave it inefficiently doing things over and over again in the middle of the night (when nobody really cares anyway).
Thanks for the input. Will do in the long run.
 
Old 01-09-2014, 09:30 AM   #7
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Quote:
Originally Posted by zhjim View Post
There is a make clean at the start of every build.
Well that would do it. "make clean" removes all the intermediate files - object files, etc. - that are used to determine if something needs to be recompiled or not. When you say "make clean", yeah, you're telling make to recompile everything again.
 
Old 01-09-2014, 09:39 AM   #8
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748

Original Poster
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Thanks for clarfying. So I found the bad guy. AS I hope this to be the last test run of the script with my changes I can start taking it apart and put some markers on individual steps so they can be skipped if allready done.

Thanks for your help haertig.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to compile inkscape,cant get past configure? rixtr66 Linux - Newbie 17 08-27-2008 06:55 AM
black screen after succesful intallation kpachopoulos Fedora 2 10-03-2007 07:49 AM
Succesful Switch to Slackware! Super! Lohan LinuxQuestions.org Member Success Stories 11 08-13-2007 05:33 AM
After a not succesful compile of the kernel, how do i recompile it? salviadud Linux - Newbie 2 02-09-2005 07:03 PM
ran a succesful basic Linux class today zaharia LinuxQuestions.org Member Success Stories 3 03-27-2004 03:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration