# About ports compilation and -j option.



## fender0107401 (Nov 17, 2008)

According to the handbook, when compiling the userland, I can use the "-j" option(# make -j4 buildworld).

So, I want to know it is possible to use the "-j" option in the ports compilation?

I am very glad to see the forum.§e


----------



## kamikaze (Nov 17, 2008)

<shameless advertising>
The port sysutils/bsdadminscripts offers some hooks to achieve that in its buildflags component.
</shameless advertising>

If you want to do it yourself you have to make sure that you only use it during _make build_. During any other stage lots of ports break. That means, especially, broken installs. Sometimes even undetected broken installs.

The buildflags hooks combined with portmaster/portupgrade work well for me. But I have to maintain a list of ports that break, about 5% of the ports I use.


----------



## s-tlk (Nov 17, 2008)

Actually I was about to say, that this could be very dangerous. I try that for some time and unfortunately I got some broken packages. :/

Afair the so called "ports 2.0" are able to compile with parallel threads.



> The buildflags hooks combined with portmaster/portupgrade work well for me. But I have to maintain a list of ports that break, about 5% of the ports I use.


Oh that sounds nice. I'll try it in future. ^^


----------



## kamikaze (Nov 17, 2008)

```
# Activate parallel builds for child makejobs.
.if defined(SUBTHREADS) && !(make(*install) || make(package))
MAKE_ARGS:=             -j${SUBTHREADS}
.endif

# Activate normal parallel builds.
.if defined(THREADS)
.MAKEFLAGS:             -j${THREADS}
.endif
```
This is from buildflags.mk. For base you'd use THREADS, for ports SUBTHREADS.

As you can see SUBTHREADS takes care that you do not run make -j with dangerous targets.


----------



## fender0107401 (Nov 17, 2008)

*Thank yours reply.*

I think that I should install and upgrade ports as normal way.

For me, it is too dangerous.

Is there any possibility, that our ports system will officially support this feature in the future?

So, everyone can easyly upgrade and deliver the multi-core cpu's potential energy.

But, I believe that this is just a little problem, nobody will upgrade ports every day.


----------



## dforsyth (Nov 17, 2008)

I worked on something kind of (maybe not) like this for Summer of Code this year.  My stuff will let multiple depedencies be handled at once, but it won't make -j work the way I think you want.  That said, it did make ports with a bunch of dependencies build a bit faster.


----------



## kamikaze (Nov 17, 2008)

Just for the record, I update my ports every day.


----------

