# UNG (Unix is Not GNU)



## ethoms (Jan 21, 2014)

Reading the 10 release announcement, and noticing the userland changes, I was surprised at how many tools have been converted to BSD licensed equivalents of GNU ones. Clean room rewrites.

On top of the move to Clang/LLVM, I was just wondering; how much GNU is left is FreeBSD base?


----------



## kpa (Jan 21, 2014)

GNU grep(1) and groff(1) at least. The first can be quite safely replaced with bsdgrep but the second one is trickier because it's needed to format the manual pages.


----------



## worldi (Jan 21, 2014)

The wiki has a page about GPL software in the base.


----------



## kpa (Jan 21, 2014)

I forgot the most important one, GNU binutils. That's a very unfortunate one because they are right now the only way to compile and link (as(1) and ld(1)) assembler code produced by C/C++ compilers into executables and the equivalent tools from the LLVM project aren't yet ready for production. The binutils in FreeBSD's base are near eight years old now and are maintained by local patches, I'm pretty sure the version that FreeBSD uses has been abandoned long ago in Linux.


----------



## SirDice (Jan 21, 2014)

kpa said:
			
		

> GNU grep(1) and groff(1) at least. The first can be quite safely replaced with bsdgrep but the second one is trickier because it's needed to format the manual pages.


There's a weird side-effect of bsdgrep though. For some reason with bsdgrep mod_alias never gets built with www/apache22. You can enable the option all day long but it's always disabled when building. There are a few other issues as well.

PR 181973


----------



## worldi (Jan 21, 2014)

SirDice said:
			
		

> There's a weird side-effect of bsdgrep though.



Interesting. It boils down to:


```
% echo foobar bar | gnugrep -w bar; echo $?
foobar bar
0
% echo foobar bar | bsdgrep -w bar; echo $?
1
```

If -w is used and the word you're looking for is part of another word it won't get detected. I'll take a closer look at it later.


----------



## ethoms (Jan 21, 2014)

I did not know that GNU grep was still the default grep. How does one replace it with bsdgrep?

@kpa: thanks for the info. It seems the binutils are partially replaced in v10:



> BSD-licensed versions of ar(1) and ranlib(1), based on libarchive(3), have replaced the GNU Binutils versions of these utilities.
> 
> BSD-licensed versions of bc(1) and dc(1) have replaced their GNU counterparts.


----------



## ethoms (Jan 21, 2014)

@worldi: thanks for the link, very useful to track the progress of UNG.


----------



## mveety (Feb 4, 2014)

You can probably replace groff with troff from Plan 9 or the heritage troff. I don't know how much man requires the specific gnu features though.


----------



## SirDice (Feb 4, 2014)

ethoms said:
			
		

> I did not know that GNU grep was still the default grep. How does one replace it with bsdgrep?


Add WITH_BSD_GREP to src.conf(5) and rebuild world. But do note the weird side-effects I mentioned earlier.


----------



## worldi (Feb 4, 2014)

I wouldn't recommend using `bsdgrep` yet. The code is awful and it's likely that it contains more bugs.


----------



## Carpetsmoker (Feb 5, 2014)

```
[~]% ls /usr/src/gnu/*
/src/src/gnu/COPYING    /src/src/gnu/Makefile
/src/src/gnu/COPYING.LIB        /src/src/gnu/Makefile.inc

/src/src/gnu/lib:
Makefile        libdialog/      libgomp/        libssp/
Makefile.inc    libgcc/         libreadline/    libstdc++/
csu/            libgcov/        libregex/       libsupc++/

/src/src/gnu/usr.bin:
Makefile        dialog/         gdb/            rcs/
Makefile.inc    diff/           gperf/          sdiff/
binutils/       diff3/          grep/           send-pr/
cc/             dtc/            groff/          texinfo/
```



			
				worldi said:
			
		

> I wouldn't recommend using bsdgrep yet. The code is awful and it's likely that it contains more bugs.



Hm, I've been using bsdgrep for quite a while, ever since it got into base, and on OpenBSD before that.
I've never encountered any problems. From what I heard, GNU grep was really awful, and BSD grep was supposed to be much cleaner...


----------



## SirDice (Feb 5, 2014)

For me it was easy to test. Just run `make -C /usr/ports/www/apache22 rmconfig config` and check /var/db/ports/www_apache22/options. Look for the ALIAS option. If you run `make -C /usr/ports/www/apache22 config` again you'll notice ALIAS has suddenly been turned off. The result of this was that without editing the options file by hand I always ended up with a missing mod_alias in my packages. 

That was the only  issue I noticed using BSD grep and why I stopped using it. It may have been fixed in the mean time though. I haven't tried it in a while.


----------



## Carpetsmoker (Feb 5, 2014)

SirDice said:
			
		

> For me it was easy to test. Just run `make -C /usr/ports/www/apache22 rmconfig config` and check /var/db/ports/www_apache22/options. Look for the ALIAS option. If you run `make -C /usr/ports/www/apache22 config` again you'll notice ALIAS has suddenly been turned off. The result of this was that without editing the options file by hand I always ended up with a missing mod_alias in my packages.
> 
> That was the only  issue I noticed using BSD grep and why I stopped using it. It may have been fixed in the mean time though. I haven't tried it in a while.



Hah, you're right!


```
--- options     2014-02-05 22:56:58.000000000 +0100
+++ /var/db/ports/www_apache22/options  2014-02-05 22:58:02.000000000 +0100
@@ -27,7 +27,7 @@
 OPTIONS_FILE_SET+=DAV_FS
 OPTIONS_FILE_UNSET+=DAV_LOCK
 OPTIONS_FILE_SET+=ACTIONS
-OPTIONS_FILE_SET+=ALIAS
+OPTIONS_FILE_UNSET+=ALIAS
 OPTIONS_FILE_SET+=ASIS
 OPTIONS_FILE_SET+=AUTOINDEX
 OPTIONS_FILE_SET+=CERN_META
```

This should really be reported. If you didn't report it, I'll do it.


----------



## worldi (Feb 5, 2014)

There's a more simple test case. The bug sits somewhere in procline(). The logic when to continue searching for further patterns is flawed.


----------



## SirDice (Feb 5, 2014)

I did report it, that's how I know it's caused by BSD grep. Unfortunately I can't seem to find the PR anymore.

Edit: Ah! Found it: PR 179634


----------



## worldi (Feb 5, 2014)

The other PR that you've mentioned earlier - PR 181973 - hasn't been closed yet.


----------



## worldi (Jun 28, 2014)

I just noticed that the fix for PR 181973 (bsdgrep regression in ports framework) got committed just recently.


----------



## Crivens (Jun 30, 2014)

kpa said:
			
		

> I forgot the most important one, GNU binutils. That's a very unfortunate one because they are right now the only way to compile and link (as(1) and ld(1)) assembler code produced by C/C++ compilers into executables and the equivalent tools from the LLVM project aren't yet ready for production.


<nitpick>
The LLVM codegenerator emits binary object files, the assembler stage is not used. But you need the assembler and linker, not everything can be written using C. Or in one file. 
</nitpick>


----------

