# Can we use multi-thread support to build ports?



## rempas (May 19, 2022)

The "-j" flags doesn't work for every port I tried. Is there a way to use true multi-thread support for every port (even with a third party program)?

*NOTE:* For anyone seeing this and not reading the replies, I'm talking about using multiple jobs (hence the "-j" flag). I didn't even knew building multiple ports concurrently is even possible...


----------



## SirDice (May 19, 2022)

It's not always possible to build things multi-threaded. In some cases you can't build something until something else was built first. They have to be built sequentially.

Do you have an example of a port where it doesn't work?


----------



## rempas (May 19, 2022)

> In some cases you can't build something until something else was built first. They have to be built sequentially.
Oh, that's interesting! So do you think trying to build the dependencies first will work

> Do you have an example of a port where it doesn't work?
Sure! For starters, I will tell you three. x11/xorg,editors/neovim and lang/ldc.
I tried to build all of them using the following command: `make -j7`


----------



## SirDice (May 19, 2022)

x11/xorg is a so-called meta port. It doesn't have anything of itself, it only depends on a bunch of other ports.


----------



## rempas (May 19, 2022)

Thank you for the info! The other two are not meta ports however, right?


----------



## Eric A. Borisch (May 19, 2022)

Check out ports-mgmt/poudriere or ports-mgmt/synth for building multiple ports in parallel.


----------



## SirDice (May 19, 2022)

rempas said:


> The other two are not meta ports however, right?


They're 'proper' ports yes. The ports themselves look like they will build multi-threaded. But they do need to install their dependencies before the port itself can be built of course.


----------



## SirDice (May 19, 2022)

Eric A. Borisch said:


> Check out ports-mgmt/poudriere or ports-mgmt/synth for building multiple ports in parallel.


Yes, good one. 

I think rempas may have some confusion with regards to `-j` to compile using multiple jobs and building ports concurrently. Those are two different things.


----------



## rempas (May 19, 2022)

Wait! I was talking about using multiple jobs (hence why I said multi-thread) not building multiple ports concurrently.


----------



## cy@ (May 21, 2022)

rempas said:


> The "-j" flags doesn't work for every port I tried. Is there a way to use true multi-thread support for every port (even with a third party program)?
> 
> *NOTE:* For anyone seeing this and not reading the replies, I'm talking about using multiple jobs (hence the "-j" flag). I didn't even knew building multiple ports concurrently is even possible...


Ports builds are multithreaded by default, without the -j.

What if you want to disable multithreaded ports builds then? make -DDISABLE_MAKE_JOBS.

If a port doesn't support multithreaded builds you will see MAKE_JOBS_UNSAFE=yes in its Makefile.


----------

