Skip to content

Commit

Permalink
allow vendor specific lib for saithrift server compile (#234)
Browse files Browse the repository at this point in the history
* allow vendor specific lib for saithrift server compile
modify dashpipeline to guarantee PWD is the makefile location

* update  saithrift server build documentation

* spellcheck

Co-authored-by: Vincent Legrand <vincentl@xsl-bos1>
  • Loading branch information
2 people authored and aputriax committed Sep 27, 2022
1 parent e25b13d commit 4709e4c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ Keysight
KVM
kvm
lang
LIBS
libsai
libprotobuf
linux
liveness
LLDP
Expand Down Expand Up @@ -441,6 +443,7 @@ rx
SAI
sai
sairedis
SAIRPC
saiserver
saithrift
sata
Expand Down
8 changes: 6 additions & 2 deletions dash-pipeline/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
SHELL = /bin/bash

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))

# "All" type targets for convenience
all:p4 sai saithrift-server docker-saithrift-client test

Expand All @@ -13,7 +16,7 @@ clean: kill-all p4-clean sai-clean test-clean network-clean saithrift-server-cle

kill-all: kill-saithrift-server kill-switch undeploy-ixiac

PWD := $(shell pwd)
PWD := $(realpath $(mkfile_dir))
DASH_USER ?=dashuser
DASH_GROUP ?=dashusers
DASH_UID ?=4321
Expand Down Expand Up @@ -102,14 +105,15 @@ $(P4_ARTIFACTS): $(P4_SRC)
# DASH SAI HEADER & libsai.so TARGETS
######################################


SAIRPC_VENDOR_EXTRA_LIBS?=""
# Note we have to mount main DASH dir to allow container to "see" the parent Git repo for the SAI submodule
DOCKER_RUN_SAITHRIFT_BLDR =\
docker run \
$(DOCKER_FLAGS) \
--rm \
--name dash-saithrift-bldr-$(USER) \
-v $(PWD)/..:/dash -w /dash/dash-pipeline/SAI/saithrift \
-e SAIRPC_VENDOR_EXTRA_LIBS=$(SAIRPC_VENDOR_EXTRA_LIBS) \
$(DOCKER_SAITHRIFT_BLDR_IMG) \

# TODO - create separate rules for headers, libsai.so
Expand Down
17 changes: 17 additions & 0 deletions dash-pipeline/README-dash-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ This builds a saithrift-server daemon, which is linked to the `libsai` library a
```
make saithrift-server
```
In the case a vendor integrates its own `libsai` library into the saithrift server, the libsai might have new external dependencies (such as google protocol buffer) thus requiring for vendor specific libraries or linker options to be passed down to the saiserver linker.
An environment variable (SAIRPC_VENDOR_EXTRA_LIBS) can be specified when invoking the saithrift server build command to provide path to new libraries and/or new linker options.
Its value will be added to the baseline SAIRPC_EXTRA_LIBS as defined in the saithrift makefile.

Since the saithrift server is built within a docker container (and the parent repository is mounted as /dash), any of the extra libraries needed will need to be copied over under the parent repository, and the paths to those libraries will need to be relative to the docker mount point.

In the example below, libprotobuf.a is a new external dependency to the vendor specific libsai.so and has been copied over under the parent repository (in our case, dash-pipeline/SAI/lib).
We use the provided Makefile.3rdpty as an entry point into the DASH makefiles.

```
SAIRPC_VENDOR_EXTRA_LIBS="/dash/dash-pipeline/SAI/lib/libprotobuf.a"
thirdparty-saithrift-server: thirdparty-libsai
@echo "Build third-party saithrift-server"
@echo " Expects libsai.so under $(DASHDIR)/dash-pipeline/SAI/lib"
SAIRPC_VENDOR_EXTRA_LIBS=$(SAIRPC_VENDOR_EXTRA_LIBS) $(MAKE) -C $(DASHDIR)/dash-pipeline saithrift-server
```

## Build libsai C++ client test program(s)
This compiles simple libsai client program(s) to verify the libsai-to-p4runtime-to-bmv2 stack. It performs table access(es).

Expand Down
3 changes: 2 additions & 1 deletion dash-pipeline/SAI/saithrift/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RPC_INST_DIR=$(shell pwd)/../rpc

META=../SAI/meta

SAIRPC_EXTRA_LIBS="\
SAIRPC_VENDOR_EXTRA_LIBS?=
SAIRPC_EXTRA_LIBS= "$(SAIRPC_VENDOR_EXTRA_LIBS) \
-L/lib/x86_64-linux-gnu -Wl,-rpath=/lib/x86_64-linux-gnu -lm \
-L/usr/local/lib/ -Wl,-rpath=/usr/local/lib \
-lpthread \
Expand Down

0 comments on commit 4709e4c

Please sign in to comment.