Recent

Author Topic: Best way to make release builds included used packages  (Read 7293 times)

MISV

  • Hero Member
  • *****
  • Posts: 783
Best way to make release builds included used packages
« on: July 28, 2015, 03:38:31 pm »
Hi,

I have my own package where I store all my own components and code.

Normally this is compiled in debug mode, so I can access breakpoints rtc.

However, for release builds I would like:
- All Lazarus packages
- All 3rd part packages
- All own packages
- All own program code

to be compiled in release mode without debug symbols

... Is that possible somehow to force a rebuild like that with options?

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Best way to make release builds included used packages
« Reply #1 on: July 29, 2015, 01:25:47 pm »
Does this page help? http://wiki.freepascal.org/Deploying_Your_Application
Otherwise you could pack whatever you have into a zip file and decompress temporarily. Or you add resources. http://wiki.freepascal.org/Lazarus_Resources
Lazarus 1.7 (SVN) FPC 3.0.0

MISV

  • Hero Member
  • *****
  • Posts: 783
Re: Best way to make release builds included used packages
« Reply #2 on: July 29, 2015, 09:28:46 pm »
I am not talking about deployment. I will try to explain better.

I have "MySharedComponentsPackage"
- Source for all my components is located in path "MySharedSource"
- It is compiled using Lazarus debug-build settings

I have my "MyExampleApplication"
- In "project options > paths" it has path "MySharedSource"
- It is compiled using lazarus release-build settings

Now... I am wondering... does my "MyExampleApplication" output (i.e. the executable) still contain debug code from "MySharedComponentsPackage"?

If i have understood correctly, "MyExampleApplication" will still contain debug code even though it was compiled with release-build settings.

However, I am in doubt since "MyExampleApplication" in its paths uses the same path as "MySharedComponentsPackage".

I am hoping to
1) Fully understand above, so I know if something contains any debug code or not.
2) Find the best/easiest way to ensure my executables do not contain any debug code




JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Best way to make release builds included used packages
« Reply #3 on: July 29, 2015, 10:56:14 pm »
I have "MySharedComponentsPackage"
- Source for all my components is located in path "MySharedSource"
- It is compiled using Lazarus debug-build settings

I have my "MyExampleApplication"
- In "project options > paths" it has path "MySharedSource"

That is a common mistake made by Delphi programmers. Library code must not be referenced by the project's path. The Path setting is only meant for project's own sub-directories.
You must make a dependency to the package instead. Then the package "injects" its paths to the project. Lazarus IDE must see the package only once and will then always find it when needed.

Quote
- It is compiled using lazarus release-build settings

Now... I am wondering... does my "MyExampleApplication" output (i.e. the executable) still contain debug code from "MySharedComponentsPackage"?

The settings defined in the package's options are used then.
You can pass the project's compiler options to all dependent packages by using the "Additions and Overrides" page in project options.
Just set the flags as Custom option there. Remember to remove the debug settings from the package's options, too.
All the project's compiler options are part of build modes, you can configure everything in "Debug" and "Release" modes and then switch them from the IDE Coolbar.

BTW, Lazarus itself is not a "normal" project yet and it is built differently.
Its dependent packages like LCL get settings defined in Configure Build Lazarus window because they use macro $(IDEBuildOptions) in their Custom Options.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MISV

  • Hero Member
  • *****
  • Posts: 783
Re: Best way to make release builds included used packages
« Reply #4 on: July 30, 2015, 12:23:19 am »
I have "MySharedComponentsPackage"
- Source for all my components is located in path "MySharedSource"
- It is compiled using Lazarus debug-build settings

I have my "MyExampleApplication"
- In "project options > paths" it has path "MySharedSource"

That is a common mistake made by Delphi programmers. Library code must not be referenced by the project's path. The Path setting is only meant for project's own sub-directories.
You must make a dependency to the package instead. Then the package "injects" its paths to the project. Lazarus IDE must see the package only once and will then always find it when needed.

I know, but it seemed hard to fix :( I also have shared units no part of components in that directory. I started trying to split it up but gave up.

Maybe I could try make sure the package uses ALL units in the directory (even if they are not necessary for the components)
Then I could possibly drop having it as a search path in my application project (?)



Quote
- It is compiled using lazarus release-build settings

Now... I am wondering... does my "MyExampleApplication" output (i.e. the executable) still contain debug code from "MySharedComponentsPackage"?

The settings defined in the package's options are used then.
You can pass the project's compiler options to all dependent packages by using the "Additions and Overrides" page in project options.
Just set the flags as Custom option there. Remember to remove the debug settings from the package's options, too.
All the project's compiler options are part of build modes, you can configure everything in "Debug" and "Release" modes and then switch them from the IDE Coolbar.

BTW, Lazarus itself is not a "normal" project yet and it is built differently.
Its dependent packages like LCL get settings defined in Configure Build Lazarus window because they use macro $(IDEBuildOptions) in their Custom Options.


Thanks!

Just to be 100% sure I understand you correctly:

I will before release need to rebuild/reinstall (using optimized release build settings) my own package before I compile my application if I want to be sure there is no info in my executable. (i.e. each time I release a new public version I should do this.)

(I understand this)

Or

I can configure my own components/shared-source package in section "Additions and Overrides" + switching off debug info.... And then my component-package-project will use same debug/release settings as defined in my application-project when rebuilding it

(or do you mean hat if I have package-project-A ... and package-project-B soly depends on package-project-A ... I can force package-project-B to always being built using the same settings as package-project-A )

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Best way to make release builds included used packages
« Reply #5 on: July 30, 2015, 11:28:29 am »
I know, but it seemed hard to fix :( I also have shared units no part of components in that directory. I started trying to split it up but gave up.

Don't give up. You can also make 2 packages.
- One contains components and is installed in Lazarus IDE.
- Other contains utility code needed by applications and maybe by components, which both then have a dependency for it.
They can be in one directory but more logical would be to place them in different directories.
Your problems may be caused by circular "spaghetti" dependencies. Everything depends on everything else. Do yourself a favor and clean it. Use abstract base classes etc. to break dependencies.

About "Additions and Overrides":
The settings there are passed to all dependent packages by default. It is also possible to pass specific settings to a specific package but I have never done it myself.

Packages are always rebuilt automatically when the flags change. You don't need to care about it once the configuration is right.
This can be seen also with LCL and other packages used by the IDE. If you build Lazarus, LCL is built with it. If you then build your application with different flags, LCL is built again. It always goes right. Don't worry.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MISV

  • Hero Member
  • *****
  • Posts: 783
Re: Best way to make release builds included used packages
« Reply #6 on: July 31, 2015, 04:16:16 pm »
Results of my tests


...


NOTE:

Before building my project I always remove "LIB" directories
for my application-project and own components-package-projects.

...


I first built my applicaion project using "RELEASE" settings.

Result = Executable was 49.198.736kb


...


I then used project options > additions and override...
Added "custom" so it looked like this:

--Stored in IDE
--Stored in project
--Stored in session of project
----Targets
--------Checked "RELEASE"

(I am not really sure if that was correctly configured
or not or if "Targets" section should be placed elsewhere?)

Result = Executable was 49.198.736kb


...


Seeing this test was inconclusive... And remembering
my application project (still, for now) has my shared
source on search path... I decided to recompile my own
components package project with release settings.
(I also removed he "lib" folder to be 100% sure)

I then built my application again using RELEASE settings.

Result = Executable was 49.198.736kb

Would the conclusion from above be that all debug info
has been stripped? Is there anything I can do to inspect
the generated executable myself? e.g. open in a hex editor
and search for specific patterns?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Best way to make release builds included used packages
« Reply #7 on: July 31, 2015, 11:34:53 pm »
I then used project options > additions and override...
Added "custom" so it looked like this:

--Stored in IDE
--Stored in project
--Stored in session of project
----Targets
--------Checked "RELEASE"

Do you mean you created a custom option named "RELEASE"?
It does not work. The options are passed to FPC, you must give flags that FPC understands.
Now I realize the buttons for creating build modes "Debug" and "Release" should add options to the "Additions and Overrides" section. It is a little complicated indeed.

Quote
(I am not really sure if that was correctly configured
or not or if "Targets" section should be placed elsewhere?)

It only affects the place where those settings are stored. You store them in session info file which is OK.

Quote
Result = Executable was 49.198.736kb

The executable always has the same size?
I think the number is bytes, not kilobytes.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MISV

  • Hero Member
  • *****
  • Posts: 783
Re: Best way to make release builds included used packages
« Reply #8 on: August 01, 2015, 06:22:38 pm »
I then used project options > additions and override...
Added "custom" so it looked like this:

--Stored in IDE
--Stored in project
--Stored in session of project
----Targets
--------Checked "RELEASE"

Do you mean you created a custom option named "RELEASE"?
It does not work. The options are passed to FPC, you must give flags that FPC understands.
Now I realize the buttons for creating build modes "Debug" and "Release" should add options to the "Additions and Overrides" section. It is a little complicated indeed.

I did it like this to indicate which build mode settings should ovveride dependents/used packages:

picture

This is what is what I meant about release:

picture




Quote
Result = Executable was 49.198.736kb

The executable always has the same size?
I think the number is bytes, not kilobytes.

Sorry bytes of course.  But yes always same size. Did the tests on OSX if that matters
« Last Edit: August 01, 2015, 08:00:50 pm by MISV »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Best way to make release builds included used packages
« Reply #9 on: August 01, 2015, 09:30:15 pm »
I did it like this to indicate which build mode settings should ovveride dependents/used packages:

picture

You forgot to set a value for the custom option. You should set :
 -O2 -g- -Xs
or similar for the release.

Quote
This is what is what I meant about release:

picture

Settings in that page affect only the project itself. Settings defined in Additions and Overrides page affect also dependent packages.

The build mode manager window (opened from the top of project options window) has a button for creating both Debug and Release modes.
A question is if settings should be added to Additions and Overrides page automatically, too. I think they should. The user can always change them if they are not needed.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MISV

  • Hero Member
  • *****
  • Posts: 783
Re: Best way to make release builds included used packages
« Reply #10 on: August 04, 2015, 12:02:56 pm »
You forgot to set a value for the custom option. You should set :
 -O2 -g- -Xs
or similar for the release.

Okay , I will be using
Code: [Select]
-O3 -g -Xs
(I changed "-g-" to "-g"  - the last "-" was an error, right?)

I have updated the screenshot

I will report back any size changes when tesing later today on OSX again.

If there is some way to inspect the results using a hex editor or similar I am still interested in that as well :)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: Best way to make release builds included used packages
« Reply #11 on: August 04, 2015, 12:59:07 pm »
(I changed "-g-" to "-g"  - the last "-" was an error, right?)

No it wasn't.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Best way to make release builds included used packages
« Reply #12 on: August 04, 2015, 02:00:24 pm »
(I changed "-g-" to "-g"  - the last "-" was an error, right?)

No it wasn't.
As in the source directive, + or - postfix enables or disables the respective feature.

MISV

  • Hero Member
  • *****
  • Posts: 783
Re: Best way to make release builds included used packages
« Reply #13 on: August 07, 2015, 02:06:10 pm »
Thanks - I have corrected it now and learn something new about Lazarus :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Best way to make release builds included used packages
« Reply #14 on: October 28, 2015, 02:12:53 pm »
I decided I wanted to add strip as an external tool. Only problem is thatt i can not find it in
/usr/local/bin/fpc/
strip is part of binutils, not fpc. check your distro's package manager.

 

TinyPortal © 2005-2018