Datadog-agent: Fail to build on FreeBSD

Created on 23 Oct 2020  路  9Comments  路  Source: DataDog/datadog-agent

Describe what happened:
I am trying to build the agent on FreeBSD so a FreeBSD-Port can be offered like https://github.com/urosgruber/dd-agent-FreeBSD for Version 5, in this repo somone said they git it built with VErsion 7 but did not yet share their code.

I had to patch rtloader/api.cpp with:

diff --git a/rtloader/rtloader/api.cpp b/rtloader/rtloader/api.cpp
index 1edf5d324..3f059e212 100644
--- a/rtloader/rtloader/api.cpp
+++ b/rtloader/rtloader/api.cpp
@@ -40,7 +40,8 @@
 #    define DATADOG_AGENT_TWO "libdatadog-agent-two.dll"
 #    define DATADOG_AGENT_THREE "libdatadog-agent-three.dll"
 #else
-#    error Platform not supported
+#    define DATADOG_AGENT_TWO "libdatadog-agent-two.so"
+#    define DATADOG_AGENT_THREE "libdatadog-agent-three.so"
 #endif

I am aware a section for a different operating system would be better, but I failed to introduce __FREEBSD__ so I went with this.

The call of invoke agent.build fails with

(.venv) [vagrant@freebsd ~/datadog-agent]$ invoke agent.build
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/home/vagrant/datadog-agent/rtloader/build
[ 25%] Built target datadog-agent-rtloader
[100%] Built target datadog-agent-three
[ 25%] Built target datadog-agent-rtloader
[100%] Built target datadog-agent-three
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/lib/libdatadog-agent-three.so
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/lib/libdatadog-agent-rtloader.so.0.1.0
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/lib/libdatadog-agent-rtloader.so.1
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/lib/libdatadog-agent-rtloader.so
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/include/datadog_agent_rtloader.h
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/include/rtloader_types.h
-- Up-to-date: /usr/home/vagrant/datadog-agent/dev/include/rtloader_mem.h
templates.go
templates.go
go generate ran successfully
package github.com/DataDog/datadog-agent/cmd/agent
        imports github.com/DataDog/datadog-agent/cmd/agent/app
        imports github.com/DataDog/datadog-agent/cmd/agent/api
        imports github.com/DataDog/datadog-agent/cmd/agent/api/agent
        imports github.com/DataDog/datadog-agent/cmd/agent/app/settings
        imports github.com/DataDog/datadog-agent/cmd/agent/common
        imports github.com/DataDog/datadog-agent/pkg/util/containers/providers/cgroup: build constraints exclude all Go files in /home/vagrant/datadog-agent/pkg/util/containers/providers/cgroup

Additional environment details (Operating System, Cloud provider, etc):
FreeBSD11.4/12.1

All 9 comments

@Corvan I'll try with what I have as my local env. Might be that things doesn't work anymore because of other dependencies in the ports.

@urosgruber That would bee cool, any help appreciated, meanwhile I try to build v6 from your repo

@Corvan looks like cgroup was introduced with datadog 7.22.0. https://github.com/DataDog/datadog-agent/commit/27f6254e723ff4d3c799e02402aac521c423b35b#diff-abe8544eb9bc5cb47c2d0fc3123ca8435e51f3ea0c35920c4dda1c0278be22df

I'm trying to see how to exclude this from agent since this is really linux only when using docker.

Thx

@Corvan I just pushed working datadog agent 7.23.1 https://github.com/urosgruber/dd-agent-FreeBSD/tree/v7-next
Let me know if it builds on your end and I'll start merging it to master.

@urosgruber, Thx I will test to build it

@Corvan I needed to revert something just an hour ago. So if it fails on some modules etc, please get the latest commit.

I got this to build successfully. Thank you again @urosgruber.
Maybe there can be a way of excluding the cgroup stuff to build on FreeBSD. But I am not expecting you to do that. Maybe project's devs could be aware of this issue and take into account, that there is demand to have this building on FreeBSD. I don't know who I could @ here to be made aware of.

@Corvan I removed cgroup from the build since it's not needed by any modules supported on FreeBSD. I'll open PR on DD repo to at least include some fixes I did and should not cause any problems with other architectures.

Was this page helpful?
0 / 5 - 0 ratings