Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions spdk_app_example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

ALL_DEPDIRS+= hello_world passthru

ifneq ($(SPDK_HEADER_DIR),)
COMMON_CFLAGS+=-I$(SPDK_HEADER_DIR)
endif

ifneq ($(SPDK_LIB_DIR),)
COMMON_CFLAGS+=-L$(SPDK_LIB_DIR)
endif

ifneq ($(DPDK_LIB_DIR),)
COMMON_CFLAGS+=-L$(DPDK_LIB_DIR)
endif
export
.PHONY: all

all: hello_world_bdev_shared_combo

static: hello_world_bdev_static

hello_world_bdev_shared_combo: passthru_shared
$(MAKE) --directory=hello_world bdev_shared_combo

hello_world_bdev_shared_iso: passthru_shared
$(MAKE) --directory=hello_world bdev_shared_iso

hello_world_no_bdev_shared_combo:
$(MAKE) --directory=hello_world alone_shared_combo

hello_world_no_bdev_shared_iso:
$(MAKE) --directory=hello_world alone_shared_iso

hello_world_bdev_static: passthru_static
$(MAKE) --directory=hello_world bdev_static

hello_world_no_bdev_static:
$(MAKE) --directory=hello_world alone_static

passthru_shared:
$(MAKE) --directory=passthru shared

passthru_static:
$(MAKE) --directory=passthru static

clean:
rm -f ./hello_world/hello_bdev
rm -f ./passthru/libpassthru_external.*
17 changes: 17 additions & 0 deletions spdk_app_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This directory is meant to demonstrate how to link an external application and bdev
module to the SPDK libraries. The makefiles contain six examples of linking against spdk
libraries. They cover linking an application both with and without a custom bdev. For each of
these categories, they also demonstrate linking against the spdk combined shared library,
individual shared libraries, and static libraries.

This directory also contains a convenient test script, test_make.sh, which automates making SPDK
and testing all six of these linker options. It takes a single argument, the path to an SPDK
repository and should be run as follows:

~~~
./test_make.sh /path/to/spdk
~~~

The application `hello_world` and bdev module `passthru_external` have been copied from their namesakes
in the top level [SPDK github repository](https://github.com/spdk/spdk) and don't have any special
functionality.
1 change: 1 addition & 0 deletions spdk_app_example/hello_world/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello_bdev
28 changes: 28 additions & 0 deletions spdk_app_example/hello_world/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Shows how to compile both an external bdev and an external application against the SPDK combined shared object and dpdk shared object.
bdev_shared_combo:
gcc $(COMMON_CFLAGS) -L../passthru -o hello_bdev ./hello_bdev.c -lpassthru_external -lspdk -lspdk_env_dpdk -ldpdk
# Shows how to compile both an external bdev and an external application against the SPDK individual shared objects and dpdk shared object.
bdev_shared_iso:
gcc $(COMMON_CFLAGS) -L../passthru -Wl,-rpath=$(SPDK_LIB_DIR),--no-as-needed -o hello_bdev ./hello_bdev.c \
-lpassthru_external -lspdk_event_bdev -lspdk_bdev -lspdk_bdev_malloc -lspdk_log -lspdk_thread -lspdk_util -lspdk_event -lspdk_env_dpdk -ldpdk
# Shows how to compile an external application against the SPDK combined shared object and dpdk shared object.
alone_shared_combo:
gcc $(COMMON_CFLAGS) -o hello_bdev ./hello_bdev.c -lspdk -lspdk_env_dpdk -ldpdk
# Shows how to compile an external application against the SPDK individual shared objects and dpdk shared object.
alone_shared_iso:
gcc $(COMMON_CFLAGS) -Wl,-rpath=$(SPDK_LIB_DIR),--no-as-needed -o hello_bdev ./hello_bdev.c -lspdk_event_bdev \
-lspdk_bdev -lspdk_bdev_malloc -lspdk_log -lspdk_thread -lspdk_util -lspdk_event -lspdk_env_dpdk -ldpdk
# Shows how to compile an external application against the SPDK archives.
alone_static:
gcc $(COMMON_CFLAGS) -o hello_bdev ./hello_bdev.c -Wl,--whole-archive -lspdk_bdev_malloc -lspdk_event_bdev -lspdk_event_copy -lspdk_event_vmd \
-lspdk_bdev -lspdk_copy -lspdk_event -lspdk_thread -lspdk_util -lspdk_conf -lspdk_trace -lspdk_log -lspdk_json \
-lspdk_jsonrpc -lspdk_rpc -lspdk_sock -lspdk_notify -lspdk_vmd -lspdk_env_dpdk -lrte_eal -lrte_mempool -lrte_ring \
-lrte_mbuf -lrte_mempool_ring -lrte_pci -lrte_bus_pci -lrte_kvargs -lrte_vhost -lrte_net -lrte_hash \
-lrte_cryptodev -Wl,--no-whole-archive -lnuma -luuid -lpthread -ldl -lrt
# Shows how to compile and external bdev and application sgainst the SPDK archives.
bdev_static:
gcc $(COMMON_CFLAGS) -L../passthru -o hello_bdev ./hello_bdev.c -Wl,--whole-archive -lpassthru_external -lspdk_bdev_malloc -lspdk_event_bdev \
-lspdk_event_copy -lspdk_event_vmd -lspdk_bdev -lspdk_copy -lspdk_event -lspdk_thread -lspdk_util -lspdk_conf -lspdk_trace \
-lspdk_log -lspdk_json -lspdk_jsonrpc -lspdk_rpc -lspdk_sock -lspdk_notify -lspdk_vmd -lspdk_env_dpdk -lrte_eal -lrte_mempool \
-lrte_ring -lrte_mbuf -lrte_mempool_ring -lrte_pci -lrte_bus_pci -lrte_kvargs -lrte_vhost -lrte_net -lrte_hash -lrte_cryptodev \
-Wl,--no-whole-archive -lnuma -luuid -lpthread -ldl -lrt
3 changes: 3 additions & 0 deletions spdk_app_example/hello_world/bdev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Malloc]
NumberOfLuns 1
LunSizeInMB 32
5 changes: 5 additions & 0 deletions spdk_app_example/hello_world/bdev_external.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Malloc]
NumberOfLuns 1
LunSizeInMB 32
[Ext_Pt]
PTE Malloc0 TestPT
Loading